PHP前端开发

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

百变鹏仔 3个月前 (09-22) #HTML
文章标签 离线

当网络浏览器开始离线工作时,onoffline 属性就会触发。您可以尝试运行以下代码来实现onoffline 属性 -

示例

<!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>