我的扩展程序运行良好。我所有的代码都从content_scripts运行。有时浏览器停留在"loading"
状态。
当我检查document.readyState
时,输出为'loading'
。
当页面停留在window.onload = some_function()
时,无法使用loading
。
我正试图做
document.onreadystatechange = function () {
var state = document.readyState
if (state == 'interactive') {
console.log('page interactive')
} else if (state == 'loading') { // never run
console.log('Page Loading...')
} else if (state == 'complete') {
console.log('Page Loaded...')
} else {
console.log('unknown')
}
}
和
if (document.readyState == 'loading') {
console.log('loading yet, wait for the event') // Never run
} else {
console.log('loaded, Now you can call the method')
}
我知道我做错了,但是我找不到解决方法。
我只想检查页面是否正在加载20秒,以便以后可以重新加载。
我需要什么: 如何检测页面正在加载?