define([], function(){ function onReady(fn) { var DOC = document, html = DOC.documentElement, W3C = document.dispatchEvent; //FF以前是没有readyState属性的 //判断body是否存在来决定DOM文档是否加载完毕 if (!DOC.readyState) { var readyState = DOC.readyState = DOC.body ? "complete" : "loading"; } //如果页面已经完全载入完毕直接执行回调函数 if (DOC.readyState === "complete") { setTimeout(fn); //现代游览器和IE>=IE9 } else if (W3C) { DOC.addEventListener('DOMContentLoaded', function(){ if (readyState) { DOC.readyState = 'complete'; } fn(); }, false); } else { ieReady(fn); } } function ieReady(fn) { try { //处理iframe中引入的页面在IE下无法通过doScroll判断DOM知否加载完毕 if (self !== top && self.document.readyState !== 'complete') { setTimeout(function(){ ieReady.call(window, fn) }) } else if (self !== top && self.document.readyState === 'complete') { arguments[0](); } else { document.documentElement.doScroll('left'); arguments[0](); } } catch (e) { setTimeout(function(){ ieReady.call(window, fn) }) } }; AS.extend({ 'onReady': onReady }); return onReady; })
时间: 2024-11-05 10:52:18