OZONE Asylum
Forums
DHTML/Javascript
Cross browser addEventListener function
This page's ID:
31837
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I am working from a tutorial trying to write a cross browser addEventListener function. I see that it works in firefox and IE but not so good in safari. Can anyone tell me how to fix my code so that it works with safari? [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Simple Event Example</title> <script type="text/javascript"> function addEventHandler(oNode, evt, oFunc, bCaptures) { if (typeof(window.event) != "undefined") oNode.attachEvent("on"+evt, oFunc); else oNode.addEventListener(evt, oFunc, bCaptures); } function onLinkClicked(e) { alert("You clicked the link!"); } function setUpClickEvent(e) { addEventHandler(document.getElementById("clickLink"), "click", onLinkClicked, false); } addEventHandler(window, "load", setUpClickEvent, false); </script> </head> <body> <a href="#" title="click me" id="clickLink">Click Me!</a> </body> </html> [/code] thanks again in advance. oh by the way im using safari on a macbook pro with osx 10.6 [small](Edited by [url=http://www.ozoneasylum.com/user/3672]Hustluz[/url] on 05-28-2010 20:44)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »