View Full Version : cross-browser events API
I'm completely new to this forum, so if this question has been asked a thousand times before, please simply post a URL. thanks :)
now, my company's bosses have been becoming increasingly frustrated at me recently, as I tend to code for Firefox first, and IE as an afterthought.
a lot of the code I have trouble with is events-based, although there are some DOM-navigation problems that I've noticed in IE.
before I launch into a probably fruitless attempt to write an API that corrects IE's DOM-mangling, I'm wondering if someone else may have already invented that particular wheel.
ideally, this would be a script which I simply link to in the head, and then write valid DOM code which automagically works.
03-17-2005, 03:34 AM
These are not API for events but are definitely a good read.
03-17-2005, 04:00 AM
Unfortunately, those links don't really answer the question I had, although they may help me if I do need to build an API myself.
What I was hoping for was something that would allow me to write code such as this:
The above code will work in Firefox, but not IE.
I can make it work by first defining addEventListener for IE:
unfortunately, that's a rather cumbersome way of doing it, as I would have to specifically fix every element in the document, and be aware that the fix may not apply to dynamically generated elements.
an ideal solution would be to apply the events fixes to the object prototypes, but IE seems to completely ignore inheritance, so there's no point doing that.
03-17-2005, 12:02 PM
Have a look at my "encapsulated anonymous functions" thread - you might like that approach -- http://www.codingforums.com/showthread.php?t=47379
But what this question comes down to, as you're seeing, is that browsers vary hugely, and there is no unified model; maybe there would be if IE wasn't so outdated, but whatever ... it's as it is :)
The best approach to most scripting is to start from the assumption that everything works as it's supposed to, unless it's known not to; then hack from there until you've covered or excluded the browsers you care about. Effectively, write for the correct case (which is usually, but not always, what Firefox does), plus exceptions (IE builds, Safari, Opera ... as necessary).
ah! that's an interesting approach.
I think it will take a bit of practice for it to sink in for me, but it does look like that's what I need.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.