JavaScript 参考手册
Navigator onLine 属性
浏览器是否在线
源代码:
点击运行 »
<!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>
运行结果:
点击运行 »