On 2004/04/06 16:48, Amir Hardon wrote:
> A great example for this issue is the W3C DOM standard addEventListener 
> function, which isn't implemented in the popular browser. The popular 
> workaround for this is checking whether addEventListener exist and if not 
> using attachEvent (Which is a microsoft invention not mentioned in the W3C 
> standard). But this is a workaround, can you say a script is standard while 
> it contains a nonstandard function?

I don't see why not. It doesn't violate the standard by *also*
supporting non-standard extensions.
(Though strictly speaking, the standard doesn't say attachEvent()
doesn't exist so relying on its nonexistence is not standard-compliant;
but that's nitpicking, since if W3C ever adds attachEvent() they're
surely to make it MSIE-compatible).

> But I haven't decided yet with what to replace attachEvent for example,
> my best alternative right now is using the popular workaround I described...
> Can anyone offer a better solution(I wish to create pages which are standard 
> as possible).

The workaround is a very reasonable solution (as long as you wrap it up
in a function and don't litter the whole page with conditionals).

Where possible, include a piece of JavaScript that emulates the standard
functionality using the MSIE functionality, and write the rest of the
page in a strictly standard-conforming way. I wonder if you can tell
MSIE to add an "addEventListener" method to all elements.

If you have existing code you don't want to change, you can do it the
other way around: emulate the MSIE functionality using the standard.
Here's a set of scripts that does this for many MSIE quirks:
  http://webfx.eae.net/dhtml/ieemu
  http://webfx.eae.net/dhtml/mozInnerHTML/mozInnerHtml.html
It claims to be Mozilla-specific, but I suspect it's actually
standard-compliant or nearly so. Alas, it doesn't work well in Konqueror
(e.g., the "setColor" demo at http://webfx.eae.net/dhtml/ieemu/js.html
fails in Konqueror, even though it looks OK according to ECMAScript 3rd
edition).

  Eran

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to