Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically creating a mousover handler using W3C DOM?

Status
Not open for further replies.

toolkit

Programmer
Aug 5, 2001
771
GB
Hi there.

I am trying to use the World Wide Web Consortium Document Object Model to traverse through a document's body. For elements that match a certain condition, I would like to assign them a mouseover (and mouseout) event handler. But I don't seem to having much luck:

Code:
if( node matches some condition ) {

    node.setAttribute( 'onmouseover', 'alert("Hello")' );

    for( var p in node ) {
        if( p.match( /^on/ ) {
            alert( p + ": " + node[p] );
        }
    }
}

Has anyone got anything similar to work?

Cheers, NEIL
 
PS: Sorry if this is a little 'off-topic'
 
it is not off topic, don't be sorry
there's a faq on it (under event handling) - you should check it
 
iza

Thanks for the reply. Unfortunately faq215-103 isn't what I need. Did you mean another?

Thanks Neil
 
i thought more about : faq216-344
actually it's more on "how to define a new event handler", but i think the idea is here
also faq216-1063 and faq216-425 can be very useful
hope this helps ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top