ononline event
ononline Event
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body ononline="onFunction()" onoffline="offFunction()"> <p>打开文件菜单点击 "离线工作(Work Offline)" 来切换在线与离线模式。</p> <p><strong>注意:</strong> ononline 和 onoffline 事件只有 Firefox 和 Internet Explorer 8 到 10 版本的浏览器支持。</p> <script> function onFunction() { alert ("你的浏览器在线工作。"); } function offFunction() { alert ("你的浏览器离线工作。"); } </script> </body> </html>
Run Instance»
Click "Run instance" button to view the online instance
Definition and usage
ononline event is triggered when the browser starts working online.
Tips: The opposite event of ononline is onoffline event.
Tip: You can also use the navigator.onLine property to determine whether the browser is in online or offline mode.
Browser support
The number in the table indicates the version number of the first browser that supports the event.
event | |||||
---|---|---|---|---|---|
ononline | Not supported | IE11 Deprecated 8.0 | 3.0 | Not supported | Not supported |
##Syntax In HTML:
<
In JavaScript: element ononline="myScript">Try it
object.ononline=function(){myScript}; Try it
object.addEventListener("online", myScript );Try it
Note: Internet Explorer 8 and earlier IE versions do not support the addEventListener() method.
Technical detailsNo | |
---|---|
No | |
Event | |
<body> |