Bookmark and Share

Plea to Mozilla

by KodefuGuru 18. August 2009 17:20

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.

KodefuGuru.GetInfo()

Chris Eargle
LinkedIn Twitter Technorati Facebook

Chris Eargle
C# MVP, INETA Community Champion


MVP - Visual C#

 

INETA Community Champions
Friend of RedGate
Telerik .NET Ninja
Community blogs & blog posts

I am a #52er

I have joined Anti-IF Campaign


World Map

Tag cloud

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010