标签:style blog color io ar sp div on cti
function ready(fn) { var completed = function() { if ( document.addEventListener ) { document.removeEventListener( "DOMContentLoaded", completed, false ); window.removeEventListener( "load", completed, false ); } else { document.detachEvent( "onreadystatechange", completed ); window.detachEvent( "onload", completed ); } fn(); } if (document.readyState === ‘completed‘) { // 页面本身已加载结束 fn(); } else if (document.addEventListener) { document.addEventListener("DOMContentLoaded", completed, false); window.addEventListener("load", completed, false); } else { document.attachEvent("onreadystatechange", completed); window.attachEvent("load", completed); } } ready(function() { console.log(1); }); console.log(3); window.onload = function() { console.log(2); } console.log(4); // 3,4,1,2
标签:style blog color io ar sp div on cti
原文地址:http://www.cnblogs.com/qiangspecial/p/4027544.html