views:

51

answers:

1

I read some HTML like:

<script for=foo event=onmouseover> ... </script>

Just wondering what the attributes for=foo event=onmouseover mean?

+5  A: 

According to the specifications of HTML 4.01/5 and XHTML those attributes are invalid. Also see the W3C specification.

But it turns out that the attributes are proprietary to Internet Explorer, they can be found on MSDN, e.g., in SCRIPT XHTML Element:

EVENT – Specifies the name of the event handler that the enclosed script is bound to

FOR – Specifies the name of the object that the event script is bound to

Two other pages talk about these attributes with more depth: EVENT Attribute and FOR Attribute. Notice that both have a note:

Standards Information

This property is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 2 World Wide Web.

This is, of course, not true.

Also see Attaching an Event Handler, which discusses the various methods with which an event handler can be bound to an element.

Marcel Korpel
@Marcel, Pekka, Sorry I forgot one line of code. Just added. It seems an piece of code working on IE...
Paul
@Paul – That's not an extra line of code (in terms of Javascript), but an extra HTML line containing a normal image element. But thanks for mentioning IE, which made me look in MSDN.
Marcel Korpel
@Marcel, You're right. it should be just "onmouseover" but without "event=" . I take back my comments.
Paul