Archive for the ‘browsers’ Category

Testing JavaScript in IE

Thursday, September 18th, 2008
Are libraries guns in the hands of children?

Image by Friedcell via Flickr

As nowadays less and less development goes on in Internet Explorer and the versions that are currently available and widely used have some quirks — to be fair they are by the book and others aren’t — I’m starting this post to have a list of stuff that you need to keep in mind if you don’t want problems when testing in IE.

  1. Trailing comma in object literals

    This is very common in multiline object definitions. someObject = {a:17,b:19,}; looks wrong but when you have a newline after everything it’s hard to find. Firefox lets it be, IE breaks silently. This one is easy to catch with JSLint.

  2. String is not an array

    Even though many languages treat it this way. Using str[i].charCodeAt() breaks while str.charCodeAt(i) doesn’t.

  3. Element ownership matters.

    This means that you have to take care when creating elements and attaching them to different documents. If you’re using jQuery beware – jQuery(someElement).append(someHtml); is ok since it will check what the owner document is but jQuery(someHtml).appendTo(someElement); might break if execution and someElement are in different documents. You can use jQuery(someHtml, someElement.ownerDocument).appendTo(someElement); though.

What I do before testing in any browser other than Firefox (Opera is sometimes even stricter) is to check with JSLint how damaged the code is. It will catch all the weirdly written code that might break a browser. And it catches that trailing comma I mentioned.

I’m quite sure the list should be longer but these are the things I encountered in the last few days. When I find more I’ll add them to the list. If you know any that are not on the list add a comment.

Reblog this post [with Zemanta]

Undocumented jQuery constructor

Wednesday, September 17th, 2008

In jQuery it is possible to create nodes in a foreign document by calling jQuery('<div>sample html</div>', foreignElement.ownerDocument);. If somebody documented this I wouldn’t have lost the last hour or so.

This is why I like wiki style documentation.

Reblog this post [with Zemanta]

Discovering Greasemonkey again

Friday, August 15th, 2008

Meissner effect: levitation of a magnet above ...Image via Wikipedia I’ve been rediscovering the joy of Greasemonkey scripts lately. For those who don’t know, Greasemonkey is one of the best extensions for Firefox ever made (the other being Zemanta of course:) that allows you to run JavaScripts on specified pages. This doesn’t really mean much to the non-technical crowd, but to us geeks this means you can do almost whatever you want with the page. As I make more and more of these I decided to share them here.

For my Slovenian readers

  1. Finance unfixed is a script that will unfix the header of finance.si. This means the header will scroll and you’ll get more space to read the article.
  2. RTVSlo OI is a script that will remove the header from the OI page on rtvslo.si again leaving you with more real estate for reading.
  3. Delo is a script that will help your eyes when reading delo.si news site since it’s small default line-height might make them hurt.

Developers

  1. JSLint highlighter will help you read the JSLint results. If you write JavaScript and don’t know what JSLint is you should go check!

How to work it

Well first you have to have Greasemonkey installed. After that installing a user script should be as simple as a click of a link. When a script activates you’ll see a little green box that will say ‘Greased’ in the top right corner. Clicking it will toggle the script – either it’s on and active (green) or off and the page looks as it would in the first place (red). You can also toggle the script with alt+g.

Reblog this post [with Zemanta]

New version of Zemanta is out

Thursday, August 14th, 2008

Book cover of Designing With Web StandardsBook cover via AmazonWe released a new version a few days ago.

It’s mostly a bugfix release on the front-end part while there are quite a few fascinating developments on the back end. The first one is that we now suggest CrunchBase links to companies and people and we also suggest images to go with that. So if you’re writing about a start-up, a funding round, investors or anything else that is present in CrunchBase you’re likely to get better suggestions.

We’ve also added Amazon book covers for books that we find in Amazon (like Designing With Web Standards by Jeffrey Zeldman or Transcending CSS by Andy Clarke).

The biggest news is that we were able to transfer the Zemanta experience to Windows Live Writer which is our first desktop application integration. I hope this brings joy to the users of Live Writer. Being the first desktop application integration it didn’t go without glitches but I hope we fixed all the bugs, even those that were found by the first users.

We also have a new home page for everybody who doesn’t yet know what we do. If you don’t have our extension/plugin installed and you’re a blogger give it a go – you won’t regret it.

Reblog this post [with Zemanta]

Caching in Firefox 3

Friday, June 27th, 2008

@tadej told me a few days ago at the Firefox 3 launch party that he had issues with the way caching is handled in Firefox 3. I didn’t have such issues myself but it reminded me that I didn’t change the caching behavior when I installed it. So yesterday I opened the preferences and found the caching options under Advanced / Network. I was not really surprised that the options for how the cache works were missing — you really don’t want your everyday Joe to change this stuff since it may affect the perceived speed of the browser.

Since this was probably just left out of the interface I opened about:config and filtered with cache which gave me a few entries. The most interesting one was browser.cache.check_doc_frequency. Unfortunately it has a numeric value with a hidden meaning. And I had no idea what that meaning is.

I googled the thing and found a mozillaZine article about it. It explains how it works — the property defines how often the browser checks for a new version of a specific file. The possible values are as follows:

0
once per session
1
everytime
2
never
3
when out of date (default)

The default is 3 which is not very good for development purposes when you want changes to take effect immediately. What you want is 1 which means that every request will go to the server every time. You’ll get many 304s but you’ll also get a 200 as soon as a file changes on the server. So I changed the value to 1 and now I’m a happy developer.

Zemanta Pixie

Firefox 3 Release Event 2008

Tuesday, June 24th, 2008

So I’ll be talking at Firefox 3 Release Event at Kiberpipa today. Feel free to come listen to the talks or just come to the party. If you can’t come you can watch the whole thing online (the link is likely to be available somewhere on the event page).