document.body.ononline
和 navigator.onLine
之间有什么区别?他们是否使用相同的 Java Script
API 来验证网络连接和断开连接(开/关)?我搜索了 google
但没有找到有希望的答案。如果两者都有自己的 API 来验证网络连接,那么使用 document.body.ononline
或 navigator.onLine
最佳答案
NavigatorOnLine.onLine documentation指出:
Returns the online status of the browser. The property returns a boolean value, with true for being online and false for being offline. The property sends updates whenever the browser's ability to connect to the network changes.
ononline documentation表明是一个事件,浏览器上线时使用,eg:
window.onload = function() {
document.body.ononline = function() { alert('browser is now ONLINE'); };
}
关于javascript - document.body.ononline 和 navigator.onLine 之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18896619/