os0x (owner)

Revisions

gist: 189016 Download_button fork
public
Description:
DOMReady
Public Clone URL: git://gist.github.com/189016.git
Embed All Files: show embed
ready.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function ready(callback){
var isLoaded = false;
if (document.addEventListener){
document.addEventListener("DOMContentLoaded", function(){
callback();
isLoaded = true;
}, false);
window.addEventListener("load", function(){
if (!isLoaded) callback();
}, false);
} else if (window.attachEvent) {
if (window.ActiveXObject && window === window.top) {
_ie();
} else {
window.attachEvent("onload", callback);
}
} else {
var _onload = window.onload;
window.onload = function(){
if (typeof _onload === 'function') {
_onload();
}
callback();
}
}
function _ie(){
try {
document.documentElement.doScroll("left");
} catch( error ) {
setTimeout(_ie, 0);
return;
}
callback();
}
}