if(window.attachEvent){ window.attachEvent("onload",uf_attachFunction); alert("ie"); } if(window.addEventListener){ alert("ff"); window.addEventListener("load",uf_attachFunction,false); } function uf_attachFunction(){ alert("test"); }
或者
if (document.all){ window.attachEvent('onload',f1())//IE中 } else{ window.addEventListener('load',f2(),false);//firefox }