Geeks With Blogs
Path Notes of a Kodefu Master blog

I had one of those problems that I had trouble resolving with a search engine this past weekend. Once it was pointed out to me what I did wrong, it was really quite simple. Basically, I needed the enter key to fire a function from a certain input textbox. I wrote up a jquery script, and it worked for IE, Chrome, and Safari, but it did not work for Firefox. Here was the script.

$("#Location").keydown(function(evt) {
    switch (event.keyCode) {
        case 13:
            findFresh();
            break;
    }
}); 

Do you see the problem? The parameter for the function is named evt, but I switched on event instead. When this was pointed out, I was perplexed that three different browsers would automagically map this parameter to a variable for me.

Then someone else told me the real reason this works in everything but Firefox: event refers to a nonstandard (if everything but Firefox is nonstandard) object known as window.event. This contains the information from the last event that was fired.

I can deal with that because I would prefer my functions to be as pure as possible, and analyzing a parameter is more pure than analyzing a global object. I changed my code to use the evt parameter and would do so even if Firefox supported window.event. However, I really do feel that Firefox goes out of its way to make a developer’s life miserable. It’s like they’re standing on the principle that if Microsoft initiated it, they want nothing to do with it.

Window.event is such a small item that one could let it slide, but what about when you need to do something with an element in JavaScript? In every other browser, you assign an ID to the element, then reference the ID directly as a variable. Not in Firefox. They force you to call document.getElementById, and this preserves no functional purity as you’re accessing the global variable document. There is no reasoning behind this other than asininity.

Message to the Mozilla team: there are hundreds of thousands of search hits related to people trying to figure out how to make their code work in Firefox. Their code works in all other major browsers, but they are wasting hours of their precious evenings and weekends pleasing users of your browser. Please consider the millions of wasted man-hours and make your browser compatible with IE, Chrome, and Safari.

Note: Cross posted from KodefuGuru.
Permalink
Posted on Tuesday, August 18, 2009 4:21 PM | Back to top


Comments on this post: Plea to Mozilla

# re: Plea to Mozilla
Requesting Gravatar...
I think the same can be said for other browsers also. There will be something which work in other browsers and not in a particular browser.
T
Left by bsenapat on Aug 18, 2009 11:56 PM

# re: Plea to Mozilla
Requesting Gravatar...
complaining about firefox's javascript engine? i guess you never tried to update more than five dom elements at once and watched internet explorer grind to a halt.
Left by len smith on Aug 19, 2009 12:04 AM

# re: Plea to Mozilla
Requesting Gravatar...
Len, I don't consider IEs javascript engine performance and Firefox's lack of support for features other browsers commonly support to be the same topic.

However, I did test it out and IE updated 10 DOM elements at once instantly.
Left by Chris Eargle on Aug 19, 2009 6:39 AM

Your comment:
 (will show your gravatar)


Copyright © Chris Eargle | Powered by: GeeksWithBlogs.net