Monday, February 25, 2008

Be Weary of Event.observe()

In a day when I thought I was safe from all the cross-browser incompatibilities, I've been bitten in the ass once again. If you're a bit confused as to why I would think such things, you obviously haven't used a Javascript framework like Prototype. Up to this point, the only cross-browser issues I've concerned myself with, are CSS ones--and boy, there still are many, even with IE7 around). So what's my latest beef with Microsoft's craptacular Internet browser? Before I can answer that, I have to take a brief moment to explain Event.observe().

Event.observe() abstracts element.addEventListener() and element.attachEvent() which basically allows a 1-to-many relationship between an element's event and its listeners. It's a great idea, and comes in handy for me personally for many projects I work on.

In and of itself, Event.observe() is pretty easy and works without problem; however, one would assume that when push comes to shove and the event gets triggered, the listeners would be called in the order they were registered in. Well, those making that assumption would be mostly correct. This is where the browser from Bizarro World, Internet "Motherf**king" Explorer, comes in. IE appears to do the exact opposite.

To better explain, I'll use some code for example. We'll use three files: index.html (I've omitted the doctype for brevity), first.js, and second.js.

index.html
<html>
<head>
<title>Mai File</title>
<script type="text/javascript" src="first.js"></script>
<script type="text/javascript" src="second.js"></script>
</head>

<body>
</body>
</html>


Note: first.js came before second.js.

first.js

var a = "first";
Event.observe(window, 'load', function(event)
{
alert("first:" + a);
});


And second.js is almost identical.

second.js

var a = "second";
Event.observe(window, 'load', function(event)
{
alert("second:" + a);
});


When we open up our favorite browser (if it's Internet Explorer, you should be castrated), and visit our page, two alerts will pop up: "first:second", and "second:second". Left of the colon tells us what script is calling the alert() (in a matter of speaking). On the right of the colon, it tells us which script set the variable 'a' last. So according to our results, the variable 'a' was set to "second" last, which second.js was parsed second like we expected. And the alerts came in the order we also expected them.

Now we try this very same page in IE, and what do we get? "second:second", and "first:second". The exact opposite. The files were parsed in the correct order, but the event listeners were called in the opposite order.

Why this is? I have no idea. What this means though is, you can't write event listeners that depend on other event listeners of the same event. This can be quite annoying for those of us who use the window.onload event for bootstrapping and have a desired "order of operations."

Labels: , ,

Monday, December 31, 2007

Why Blink 182 Sucks

[an excerpt from a Facebook Group Thread]

Blink 182 fans are inherently hypocrites. If there's any oxymoron here, it's "Pop-Punk." Punk is rooted in anti-establishment and anti-corporate movements. Blink's very essence contradicts this very message. You can't be a punk, and milk the very corporations you claim to detest.

At no point in Blink 182's career, did I ever get the impression that they were ever truly punk at heart. They always appeared to be MTV-cookie-cutout synthetic-punksters. In lesser terms, they were tools. Tools, who's only purpose was to make money for the corporations they represent.

Their music was mediocre at best. With the exception of a few tunes (I admit, "Adam's Song" wasn't all that bad), it was all very monotonous. Every song sounded exactly the same. So, any originality (if any) they had quickly faded. Unfortunately for many, these rhythmic and melodic boundaries are intentional, as they maximize a bands popularity (a concept well-known by the music industry). For those with limited musical taste, consistent and repetitive sounds have the musical attraction of a moth's irresistance to fly into a bug zapper. This is the exact science behind Pop music. It works. It makes money.

For those of you Blink 182 fans who are incapable of arguing with me in a civilized manner, don't bother replying to me. Calling us anti-Blink people "Emo Fags" is not acceptable. It does not fare well in your argument, nor is it at all relevant. If you're going to argue, do it right. Argue my my above points, or not at all. I'm neither a fag, or an emo. Not that it matters, but emo's aren't real punks either. They lack a certain necessary backbone.

Labels: ,

Thursday, May 03, 2007

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

That is all.

Labels:

Saturday, November 11, 2006

[adult swim] Fix: Now Requires ActiveX

[adult swim],
Shame on you. I thought you were one of us, "The Fix" requires ActiveX now!

What about the Linux users? What about the Mac users? What about the reluctant Windows user who refuses to install ActiveX, the one thing about Internet Explorer that makes it a heaping pile of crap, on his or her Open-Source, Standards compliant, browser. Don't sell out to Microsoft! Just because Google is kicking their ass, doesn't mean they're not threatening.

Digg!

Labels:

Tuesday, July 18, 2006

The REAL Facts behind Microsoft

  • Internet Explorer causes cancer
  • Terrorists use Internet Explorer to build weapons of mass destruction
  • Microsoft has Lobbyists in D.C. to abolish the Emancipation proclamation
  • Microsoft uses child slavery to build it's 360's
  • Bill Gates is a pedophile
  • Steve Ballmer eats babies, and beats his wife
  • ActiveX (used by Internet Explorer) is a highly contagious Sexually Transmitted Disease
  • Internet Explorer killed my father and raped my mother
  • Microsoft sells credit card information acquired through Internet Explorer to Abortion Clinics and Assisted Suicide Centers
  • The Halo Saga uses subliminal queues to convince players to start fires in their sleep
Support Honest Business Practice, Use FireFox
www.mozilla.com

Labels: