js判断页面加载完成绑定事件

来源:互联网 发布:淘宝买家秀和卖家秀 编辑:程序博客网 时间:2024/05/05 21:32
bindReady: function () {    if (this.readyBound) {        return;    }    this.readyBound = true;    if (document.readyState === "complete") {        return setTimeout(this.ready, 1);    }    if (document.addEventListener) {        document.addEventListener("DOMContentLoaded", this.DOMContentLoaded, false);        window.addEventListener("load", this.ready, false);    } else {        if (document.attachEvent) {            document.attachEvent("onreadystatechange", this.DOMContentLoaded);            window.attachEvent("onload", this.ready);            var toplevel = false;            try {                toplevel = window.frameElement == null;            } catch (e) {            }            if (document.documentElement.doScroll && toplevel) {                doScrollCheck();            }        }    }},
0 0
原创粉丝点击