Is the HTML document ready

Is document ready

The readyState property returns three different values.

ValueDescription
loadingThe browser is loading the document.
interactiveThe document has been parsed, but the browser is still loading linked resources.
completeThe document has been parsed and all of the resources have been loaded.

The value of the readyState property moves from loading to interactive to complete.

The readystatechange event is triggered each time the value of the readyState property changes.

Example


<!DOCTYPE HTML> 
<html> 
    <head> 
        <script> 
            document.onreadystatechange = function() { 
                if (document.readyState == "interactive") { 
                    alert("results"); 
                } <!--   w  w  w. j  a v a 2s .com-->
            } 
        </script> 
    </head> 
    <body> 
    </body> 
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window