readystatechange
        
        
          
                Baseline
                
                  Widely available
                
                
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since julho de 2015.
O evento readystatechange é ativado quando o atributo readyState de um documento é alterado.
Informações gerais
- Especificação
 - Interface
 - 
Event
 - Propaga
 - 
Não
 - Cancelável
 - 
Não
 - Alvo
 - 
Document
 - Ação Padrão
 - 
Nenhuma.
 
Propriedades
| Property | Type | Description | 
|---|---|---|
target Somente leitura  | 
EventTarget | 
The event target (the topmost target in the DOM tree). | 
type Somente leitura  | 
DOMString | 
The type of event. | 
bubbles Somente leitura  | 
Boolean | 
Whether the event normally bubbles or not. | 
cancelable Somente leitura  | 
Boolean | 
Whether the event is cancellable or not. | 
Exemplo
js
// alternativa ao DOMContentLoaded
document.onreadystatechange = function () {
  if (document.readyState == "interactive") {
    initApplication();
  }
};
Compatibilidade com navegadores
Este evento tem sido suportado pelo Internet Explorer há várias versões, e pode ser usada como uma alternativa para o evento DOMContentLoaded (veja a seção cross-browser fallback).