What is the difference between Window.load and document.readyState
        Posted  
        
            by prakash
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by prakash
        
        
        
        Published on 2010-03-16T19:21:46Z
        Indexed on 
            2010/03/16
            19:31 UTC
        
        
        Read the original article
        Hit count: 337
        
Hi All,
I have one question , In my ASP.NET MVC web application i have to do certain validation once page and all controls got loaded.
In javascript i was using belwow line of code for calling a method.
window.load = JavascriptFunctionName ; 
Some one from my team asked me not used above line of code Instead use JQuery to do the same
 document.attachEvent("onreadystatechange", function() {
        if (document.readyState === "complete") {
            CheckThis();
        }
    });
Please help me in understanding what is the difference between two. When i tested by keeping alert in both Jquery check is executing first and calling the CheckThis function where as window.load is taking some time and executing after it. Please suggest
© Stack Overflow or respective owner