运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <h1>HTML DOM Events</h1> <h2>The ononline Event</h2> <body ononline="onFunction()" onoffline="offFunction()"> <p><b>NOTE:</b> There will only be an "output" from this example when the browser shifts from offline to online.</p> <p id="demo"></p> <script> function onFunction() { document.getElementById("demo").innerHTML = "Your browser is working online."; } function offFunction() { document.getElementById("demo").innerHTML = "Your browser is working offline."; } </script> </body> </html>