当前位置:网站首页>Document. How to use and listen for readyState

Document. How to use and listen for readyState

2022-06-22 00:34:00 October oooo

Document.readyState How to use and listen

Document. readyState There are three states

  • loading: The document is still loading
  • interactive: The body of the document has been loaded , But attached pictures 、js、css What's still loading
  • complete: Loading complete

Listening usage

document.onreadystatechange = event => {
    
	console.log(event)
	console.log(document.readyState)
}

When document When the state changes , Will trigger docuemnt.onreadstatechange event , The contents of this event are as follows :

 Insert picture description here

document.onreadystatechange = event => {
    
   console.log(event.timeStamp, document.readyState)
}

You can see the event changes corresponding to the time :

 Insert picture description here

原网站

版权声明
本文为[October oooo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206212254295132.html