<body>
    <h1 >websong</h1>
</body>
<script>
    var text=document.querySelector('#text').innerText;
    setInterval(function () {
        if (navigator.onLine) {
            //alert('online:有网络');
            document.querySelector('#text').style.color='red';
            document.querySelector('#text').innerText=text+'您的网络恢复了'
        } else {
            //alert('offline:断开网络');
            document.querySelector('#text').style.color='blue';
            document.querySelector('#text').innerText=text+'您断网了'
        }
    },1000)
</script>

  亲测在各个浏览器都可以跑,当然,低版本的我没试。

相关文章:

  • 2022-12-23
  • 2021-11-02
  • 2021-11-08
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案