Created
February 4, 2013 18:12
-
-
Save manix84/4708435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var utils = window.utils || {}, | |
domLoaded = false; | |
utils.domready = function (callback) { | |
/* Internet Explorer */ | |
/*@cc_on | |
@if (@_win32 || @_win64) | |
document.write("<script id="ieScriptLoad" defer src=\"//:\"><\/script>"); | |
document.getElementById("ieScriptLoad").onreadystatechange = function() { | |
if (this.readyState == "complete") { | |
domLoaded = true; | |
callback(); | |
} | |
}; | |
@end @*/ | |
if (document.addEventListener) { | |
/* Mozilla, Chrome, Opera */ | |
document.addEventListener("DOMContentLoaded", function () { | |
domLoaded = true; | |
callback(); | |
}, false); | |
} else if (/KHTML|WebKit|iCab/i.test(window.navigator.userAgent)) { | |
/* Safari, iCab, Konqueror */ | |
var DOMLoadTimer = window.setInterval(function () { | |
if (/loaded|complete/i.test(document.readyState)) { | |
domLoaded = true; | |
callback(); | |
window.clearInterval(DOMLoadTimer); | |
} | |
}, 10); | |
} else { | |
/* Other web browsers */ | |
window.onload = function () { | |
domLoaded = true; | |
callback(); | |
}; | |
} | |
if (domLoaded) { | |
callback(); | |
} | |
}; | |
window.utils = utils; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment