美文网首页
页面加载完成提示

页面加载完成提示

作者: silentsvv | 来源:发表于2017-09-16 22:07 被阅读0次

主要说明的有两个关键的元素document.onreadystatechangedocument.readyState

#document.onreadystatechange


The readystatechange event is fired when the readyState attribute of a document has changed.

当readyState状态变化的时候,就会触发onreadystatechange的事件

#document.readyState


The Document.readyState property of a document describes the loading state of the document.

readyState来表示页面加载状态,有以下三个属性:

  1. loading (加载document元素)
  2. interactive (document元素加载完成,但是图片,样式等还没加载完成)
  3. complete (页面加载完成)

实例


document.onreadystatechange = function() {
  if(document.readyState == "complete"){
    console.log("页面加载完成")
  }
}

相关文章

网友评论

      本文标题:页面加载完成提示

      本文链接:https://www.haomeiwen.com/subject/wrbusxtx.html