I moved this blog to other domain: https://tech.panshin.me , please update your bookmarks

Monday, May 4, 2009

Attach multiple functions to events

Attach multiple functions to events

Attach multiple functions to events

The function that need to place some wear on page:

function addEvent(obj, evType, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else
{
return false;
}
}

Sample to call the function:

addEvent(window, 'load', functionName);

No comments: