标签:lin document get com offline function als cti logs
https://www.cnblogs.com/CyLee/p/5899568.html
http://zccst.iteye.com/blog/2194229
获取用户的联网状态
复制代码
if (navigator && navigator.onLine === false) {
alert("无法连接网络")
}
else
{
alert("正常上网")
}
复制代码
监听事件
复制代码
var el = document.body;
if (el.addEventListener) {
window.addEventListener("online", function () {
alert("online");}, true);
window.addEventListener("offline", function () {
alert("offline");}, true);
}
else if (el.attachEvent) {
window.attachEvent("ononline", function () {
alert("online");});
window.attachEvent("onoffline", function () {
alert("offline");});
}
else {
window.ononline = function () {
alert("online");};
window.onoffline = function () {
alert("offline");};
}
复制代码
Js navigator.onLine 获取设备是否可以上网、连接网络
标签:lin document get com offline function als cti logs
原文地址:https://www.cnblogs.com/ellafive/p/14241084.html