经测试android ipad默认的浏览器支持,用appcan封装的网页也支持
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>网络在线与离线</title>
</head>
<body>
<div id="status"></div>
<script type="text/javascript" language="javascript" charset="utf-8">
$$=function(id){return document.getElementById(id);};
if(navigator.onLine){$$("status").innerHTML="第一次加载时在线";}else{$$("status").innerHTML="第一次加载时离线";}
window.addEventListener("online",online,false);
function online(){$$("status").innerHTML="on";}
window.addEventListener("offline",offline,false);
function offline(){$$("status").innerHTML="off";}
</script>
</body>
</html>
文章转自:http://www.cnblogs.com/lear/archive/2013/11/06/3410074.html
时间: 2024-10-11 03:57:44