Let me again say, i hate IE.
One of the pages broke, rather badly, i'd note, due to a rather annoying problem. Granted, i was having a helluva time thinking straight today, but that's beside the point. The crux of the problem was that we've got two seperate items that both want to be loaded as part of the javascript OnLoad command. They both do some setup that needs to occur after everything is properly configured, up and happy.
While i've got control over one of the items on the page, there occasionally are others i don't have control over that all dutifully set themselves as being the "Ultimate OnLoad Function" and generally screw things to the Sheboygan and back. These are sneaky little bastard functions that worm their way onto my page via all sorts of inadvertently malicious means.
So to solve this little issue once and for f*ing all, i decided that one of the very last things that the page would do is call my nice serialized initialization function that (in turn) called the various functions that all insist on being called at the "OnLoad" event.
One of the very last things occuring on the page is a script that does:
<script language="javascript">
window.onload=pageInit();
<script>
This, of course worked flawlessly in Mozilla, Firefox and Opera, but significantly less flawlessly in Internet Explorer, which complained that doing the above was "Not Implemented".
Not Implemented? You're kidding me, right?
Turns out that the "problem" is that i'm trying to overwrite the window.onload value already set earlier in the page, and that Microsoft in it's finite wisdom has determined that this might be bad. *grumble*
So, now that i've solved the problem for 99% of the browsers, i now have to solve the problem for the browser of 99%.
Turns out that Microsoft also uses an equally invalid hack to set a block of code to be executed on an event:
<script language="javascript" for="window" event="onLoad()">
pageInit();
</script>
As an added bonus, no other browser supports this.
So this leaves me in a quandry. Although i *could* build the page with the proper smarts to only display one selection based on the identifying browser ID, and may still) that's CPU wasteful on some machines i want to keep the CPU count low on.
Well, another IE bug comes to the rescue. Turns out that if you call
window.attachEvent(onLoad,pageInit); on a page that already has an onLoad assigned to it, IE ignores the request, and also doesn't bitch about it. It just ignores it completely.
So, now the new block of code reads:
<!-- set up the IE specific call (ignored by civilized browsers) -->
<script language="javascript" for="window" event="onLoad()">
pageInit();
</script>
<!-- Make sure that our code gets called (ignored by IE) -->
<script language="javascript">
window.attachEvent(onload,pageInit);
</script>
And once again, peace rules in the valley. You know, i can hardly wait until i don't have to deal with crap like that again.
Ok, that's what i get for posting something at three in the morning. Doing some additional testing, firefox also respects the "for=… on=…" so just the one function would work fine for both.
Oh look, more forehead shaped desk dents.