if (typeof window.addEventListener != "undefined") { window.addEventListener("load",rollover); } else { window.attachEvent("onload",rollover) } function rollover(){ alert("ok"); }