function ready(fn){ if(document.addEventListener){//标准浏览器 document.addEventListener('DOMContentLoaded',function(){ //注销时间避免重复触发 document.removeEventListener('DOMContentLoaded',arguments.callee,false) fn();//执行函数 },false); }else if(document.attachEvent){//IE document.attachEvent('onreadystatechange',function(){ if(readyState=='complete'){ document.detachEvent('onreadystatechange',arguments.callee); fn();//执行函数 } }); } };