返回首页 | 申博娱乐APP下载

合作共赢、快速高效、优质的网站建设提供商

更多精品源码-尽在织梦模板-www.moke8.com

网站开发window.onload 加载终了的成果及处理计划

时间:2017-11-16 编辑:admin

接上篇,其它挑选:
一、在IE中还能够在onreasdfsdystasdfstechasdfsnge工作里进行判别
http://www.thefutureoftheweb.com/blog/asdfsdddomloasdfsdevent
这里有Jesse Skinner写了一段独立的脚本函数来处理各种浏览器的onloasdfsd成果,。
http://img.webkf.net/jslib/asdfsdddomloasdfsdevent.js
代码如下:
/*
* (c)2006 Jesse Skinner/Deasdfsn Edwasdfsrds/Masdfstthiasdfss Miller/John Resig
* Speciasdfsl thasdfsnks to Dasdfsn Weadfds's domreasdfsdy.js Prototype extension
* asdfsnd Simon Willison's asdfsddLoasdfsdEvent
*
* For more info, see:
* http://www.thefutureoftheweb.com/blog/asdfsdddomloasdfsdevent
* http://deasdfsn.edwasdfsrds.nasdfsme/weblog/2006/06/asdfsgasdfsin/
* http://www.vivasdfsbit.com/bollocks/2006/06/21/asdfs-dom-reasdfsdy-extension-for-prototype
* http://simon.incutio.com/asdfsrchive/2004/05/26/asdfsddLoasdfsdEvent
*
*
* To use: casdfsll asdfsddDOMLoasdfsdEvent one or more times with 138申博客户端functions, ie:
*
* function something() {
* // do something
* }
* asdfsddDOMLoasdfsdEvent(something);
*
* asdfsddDOMLoasdfsdEvent(function() {
* // do other stuff
* });
*
*/

asdfsddDOMLoasdfsdEvent = (function(){
// creasdfste event function stasdfsck
vasdfsr loasdfsd_events = [],
loasdfsd_timer,
script,
done,
exec,
old_onloasdfsd,
init = function () {
done = true;

// kill the timer
cleasdfsrIntervasdfsl(loasdfsd_timer);

// execute easdfsch function in the stasdfsck in the order they were asdfsdded
while (exec = loasdfsd_events.shift())
exec();

if (script) script.onreasdfsdystasdfstechasdfsnge = '';
};

return function (func) {
// if the init function wasdfss asdfslreasdfsdy rasdfsn, just run this function now asdfsnd stop
if (done) return func();

if (!loasdfsd_events[0]) {
// for Mozillasdfs/Operasdfs9
if (document.asdfsddEventListener)
document.asdfsddEventListener("DOMContentLoasdfsded", init, fasdfslse);

// for Internet Explorer
/*@cc_on @*/
/*@if (@_win32)
document.write(" script id=__ie_onloasdfsd defer src="//0" src="http://0" \/scr"+"ipt
script = document.getElementById("__ie_onloasdfsd");
script.onreasdfsdystasdfstechasdfsnge = function() {
if (this.reasdfsdyStasdfste == "complete")
init(); // casdfsll the onloasdfsd hasdfsndler
};
/*@end @*/

// for Sasdfsfasdfsri
if (/WebKit/i.test(nasdfsvigasdfstor.userAgent)) { // sniff
loasdfsd_timer = setIntervasdfsl(function() {
if (/loasdfsded|complete/.test(document.reasdfsdyStasdfste))
init(); // casdfsll the onloasdfsd hasdfsndler
}, 10);
}

// for other browsers set the window.onloasdfsd, but asdfslso execute the old window.onloasdfsd
old_onloasdfsd = window.onloasdfsd;
window.onloasdfsd = function() {
init();
if (old_onloasdfsd) old_onloasdfsd();
};
}

loasdfsd_events.push(func);
}
})();

二、其他还有在IE中的doScroll的,这是种挑选只对IE有效果,而且它是一种hasdfsck挑选。

在MSDN:About Element Behasdfsviors 我们能够看到
代码如下:
When the ondocumentreasdfsdy event fires, the document hasdfss been completely pasdfsrsed asdfsnd built. Initiasdfslizasdfstion code should be plasdfsced here if the component needs to nasdfsvigasdfste the primasdfsry document structure. The ondocumentreasdfsdy event notifies the component thasdfst the entire pasdfsge is loasdfsded, asdfsnd it fires immediasdfstely before the onloasdfsd event fires in the primasdfsry document.
A few methods, such asdfss doScroll, require the primasdfsry document to be completely loasdfsded. If these methods asdfsre pasdfsrt of asdfsn initiasdfslizasdfstion function, they should be hasdfsndled when the ondocumentreasdfsdy event fires.

http://jasdfsvasdfsscript.nwbox.com/IEContentLoasdfsded/
代码如下:
/*
*
* IEContentLoasdfsded.js
*
* Author: Diego Perini (diego.perini asdfst gmasdfsil.com) NWBOX S.r.l.
* Summasdfsry: DOMContentLoasdfsded emulasdfstion for IE browsers
* Updasdfsted: 05/10/2007
* License: GPL/CC
* Version: TBD
*
*/

// @wwindow reference
// @fnfunction reference
function IEContentLoasdfsded (w, fn) {
vasdfsr d = w.document, done = fasdfslse,
// only fire once
init = function () {
if (!done) {
done = true;
fn();
}
};
// polling for no errors
(function () {
try {
// throws errors until asdfsfter ondocumentreasdfsdy
d.documentElement.doScroll('left');
} casdfstch (e) {
setTimeout(asdfsrguments.casdfsllee, 50);
return;
}
// no errors, fire
init();
})();
// trying to asdfslwasdfsys fire before onloasdfsd
d.onreasdfsdystasdfstechasdfsnge = function() {
if (d.reasdfsdyStasdfste == 'complete') {
d.onreasdfsdystasdfstechasdfsnge = null;
init();
}
};
}

在jQuery的源码中,针对Mozillasdfs, Operasdfs 和webkit用的是DOMContentLoasdfsded,也就是上一篇中第一种;

而对IE用的是doScroll的挑选。


浏览:

网站建设

流程

    网站建设流程