readystatechange

O evento readystatechange é ativado quando o atributo readyState de um documento é alterado.

Informações gerais

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 (en-US) (veja a seção cross-browser fallback).

Eventos Relacionados