HTML onreadystatechange Event Attribute

Description

The event attribute onreadystatechange occurs when the load state of the data that belongs to an element or a HTML document changes.

Syntax

<element onreadystatechange="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
   <title>onreadystatechange event example</title>
<script type="text/javascript">
   // Internet Explorer and Opera
   document.onreadystatechange = WaitForComplete;
        
   function WaitForComplete() {
      alert ("The state of the document: " + document.readyState);
   }		
   function OnLoad() {
      alert ("The document has been loaded.");
   }
</script>
</head>
<body onload="OnLoad()">
<p>onreadystatechange event example</p>
</body>
</html>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
??????
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
??????