美文网首页
js 判断浏览器是否使用外网

js 判断浏览器是否使用外网

作者: 多多VS串串 | 来源:发表于2018-09-12 12:00 被阅读0次
<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to see if the browser is online.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var x=navigator.onLine;
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

点击Try it true 是用外网 false是内网

相关文章

网友评论

      本文标题:js 判断浏览器是否使用外网

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