document.readyState

In this chapter you will learn:

  1. Check to see if 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.

<!DOCTYPE HTML> <!--  j  a v  a2s  .c  o  m-->
<html> 
    <head> 
        <script> 
            document.onreadystatechange = function() { 
                if (document.readyState == "interactive") { 
                    alert("results"); 
                } 
            } 
        </script> 
    </head> 
    <body> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to get and set document title in Javascript
  2. How to change the document title
Home » Javascript Tutorial » Document
Document Object
document.body
document.characterSet
document.charset
document.compatMode
document.cookie
document.defaultCharset
document.defaultView
getElementsByTagName(tagName)
document.getElementsByClassName
document.getElementsByName
document.images
document.lastModified
document.location
document.implementation
document.querySelectorAll
document.readyState
document.title
document.URL
document.writeln