在 HTML 中,浏览器开始在线工作时执行脚本?

htmlweb developmentfront end technology更新于 2025/8/15 20:28:17

当 Web 浏览器开始在线工作时,ononline  属性会被触发。您可以尝试运行以下代码来实现 ononline  属性。 −

示例

<!DOCTYPE html>
<html>
   <body ononline = "onlineFunc()" onoffline = "offlineFunc()">
      <script>
         function onlineFunc() {
            alert ("Working online!");
         }
         function offlineFunc() {
            alert ("Workinf offline!");
         }
      </script>
      <p>Got o the web browser menu bar and click the File menu. Select
      "Work Offline" and toggle between online and offline.</p>
   </body>
</html>

相关文章


有用资源