Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy.
OK
Note: The ononline event is supported in Internet Explorer from version 8 and in Firefox from version 3.
You can switch between working online and offline with the Work Offline menu item under the File menu in Internet Explorer and Firefox.
The ononline event only occurs if the browser is working offline and it starts to work online.
The ononline event does not fire during the page load regardless that the browser is working online.
You can get whether the browser is working online or offline with the onLine property.
If you need to detect when the browser starts to work offline, use the onoffline event.
The event object is accessible to all event handlers in all browsers.
The properties of the event object contain additional information about the current event.
To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
Setting the browser to work online with the Work Offline menu item under the File menu.
Example HTML code 1:
This example illustrates the use of the ononline and onoffline events and the onLine property:
<head><scripttype="text/javascript">function OnLoad () {
if ('onLine'innavigator) {
if (navigator.onLine) {
alert ("Your browser is working online.");
}
else {
alert ("Your browser is working offline.");
}
}
else {
alert ("Your browser does not support the onLine property.");
}
}
function OnOnline () {
alert ("Your browser starts to work online.");
}
function OnOffline () {
alert ("Your browser starts to work offline.");
}
</script></head><bodyonload="OnLoad ()"ononline="OnOnline ();"onoffline="OnOffline ();">
Please click on the Work Offline menu item under the File menu to switch between working online and offline.
</body>