I’ve made several updates to existing layouts. Most notable is a bit of an update to the ever useful ruthsarian_utilities.js. I’ve updated the
event_attach function so that it actually works as intended. More on that in a bit. I also removed my own min-width emulation code for IE and am sticking strictly to the PVII code because, as I found out, there are some serious issues with my approach on older browsers. I also went through and added proper attribution/credits which should have been there from the very beginning.
I’ve moved all the skidoo-based layouts back to HTML 4.01 strict DTDs. The reason is simple enough, XHTML specs specify that to be correct XHTML, your web server should return a mime-type of
application/xhtml+xml when serving XHTML documents. However, most return the HTML mime-type of
text/html. Also, a number of browsers will display the page as plain text if given the XHTML mime-type. Opera 7.01 and later accepts that mime-type, and you can reghack IE to do so as well. But in the interests of being “correct”, I’m converting back to HTML 4.01 strict.
So if you’re playing around with one of these templates, you might want to pick up a copy of the updated version.
Now, back to the
event_attach stuff. IE supports a
window.attachEvent which will allow you to apply multiple functions to the onload event. (Opera supports this as well.) However Gecko-based browsers do not. For those, we’re left with the old school
window.onload = myFunc;. So to attach multiple function to an event I created the
event_attach function which creates an array for a given event and populates the array with pointers to the functions you want to execute on that event.
One sticky problem: order of execution. With IE, the last function attached, is the first to execute, a method known as LIFO. Opera’s version of the window.attachEvent does just the opposite; it’s FIFO. So which do I emulate for non-attachEvent browsers? Since IE has the larger marketshare, I decided to mimic IE. I prefer the method Opera uses, but I’m playing to real-world usage here.
Another approach would be to ditch using the window.attachEvent function alltogether. However I prefer to use functionality if it’s there, rather than reinvent the wheel. But if you feel otherwise, feel free to alter the script to your liking.