Archive for the ‘javascript’ Category

jQuery window.name transport is out…

Wednesday, October 1st, 2008
JQuery intermediate site

Image by Phillie Casablanca via Flickr

After a week of mostly testing and fine-tuning the code I finally released the windowName transport plugin for jQuery. You can get the plugin here but I suggest you first check the plugin page.

I need help testing

If you have an obscure browser / OS combination that is supported by jQuery I urge you to test the plugin. There are no good test pages yet so my temporary test page will have to do. The test page POSTs the querystring passed to it to a nonlocal domain and should open a JavaScript alert with the same querystring plus php=true.

On a sidenote – I figured out that the page looks better without the background images. So I changed the theme – let me know what you think.

Reblog this post [with Zemanta]

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]

Reading JavaScript

Thursday, August 28th, 2008

Douglas CrockfordImage by Edd Dumbill via Flickr I’ve just received two books about JavaScript that will keep me entertained over the weekend. The first one is from the father of JSON, JSLint and JSmin Douglas Crockford, whose series of lectures on JavaScript is really a great video introduction from beginner to intermediate and sometimes even pro level and is called Javascript: The Good Parts. I haven’t even tried to look at it because I’m scared I’ll start reading it and won’t get any sleep.

The other one is from the new kid on the block, the jQuery author and JavaScripter extraordinaire John Resig, called Pro Javascript Techniques. Reading the jQuery code is always one of the most fascinating parts of work, so I just had to order it.

I’ll try to post a review of both of them as soon as possible, but it might be later than I hope since I have a lot to do in these coming weeks.

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]

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).