zoukankan      html  css  js  c++  java
  • jquery ready vs domcontentloaded

    Assuming browser that supports the event:

    1. The real event can support any document. jQuery will only use the document it was loaded in, no matter what you pass to it.
    2. jQuery will fire the event asynchronously even if the event has already happened. Attaching 'DOMContentLoaded' event will do nothing if the event has already happened.

    There is no delay in these browsers, see http://jsfiddle.net/rqTAX/3/ (the offsets logged are in milliseconds).

    For browsers that don't support the event, jQuery's will obviously work for them as well. It will use a hacky mechanism that is not the same as the real DOMContentLoaded and will not necessarily fire as soon as the real DOMContentLoaded would:

    // The DOM ready check for Internet Explorer
    function doScrollCheck() {
        if ( jQuery.isReady ) {
            return;
        }
    
        try {
            // If IE is used, use the trick by Diego Perini
            // http://javascript.nwbox.com/IEContentLoaded/
            document.documentElement.doScroll("left");
        } catch(e) {
            setTimeout( doScrollCheck, 1 );
            return;
        }
    
        // and execute any waiting functions
        jQuery.ready();
    }
  • 相关阅读:
    深入NET框架
    解决idea中maven的pom文件不会自动下载jar包问题
    JSP中的作用域
    转发与重定向
    JSP内置对象
    JNDI与连接池
    文件上传
    七大设计原则
    第六章 初始继承和多态
    C#和.NET框架
  • 原文地址:https://www.cnblogs.com/aloha/p/5255175.html
Copyright © 2011-2022 走看看