Jump to content
Killersites Forums

f (typeof(window.event) != "undefined") { problem


Recommended Posts

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…

<html xmlns="http://www.w3.org/1999/xhtml" >


<title>Simple Event Example</title>

<script type="text/javascript">

function addEventHandler(oNode, sEvt, fFunc, bCaptures){

if (typeof(window.event) != "undefined") {

oNode.attachEvent("on" + sEvt, fFunc);


oNode.addEventListener(sEvt, fFunc, bCaptures);




function onLinkClicked(e) {

alert("You clicked the link");



function setUpClickHandler() {

addEventHandler(document.getElementB… "click", onLinkClicked, false);


addEventHandler(window,"load", setUpClickHandler, false);




<a href="#" title="click me" id="clickLink">Click Me!</a>





I got this out of a tutorial

This works fine in FIREFOX. In CHROME and INTERNET EXPLORER 9 this doesn't work.

Please help me find the fix.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...