document.addEventListener("DOMContentLoaded", function (event) {
alert("DOM fully loaded and parsed");
});
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
// использование
ready(function(){
alert("DOM fully loaded and parsed");
});