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 onoffline 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 onoffline event only occurs if the browser is working online and it starts to work offline.
The onoffline event does not fire during the page load regardless that the browser is working offline.
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 online, use the ononline 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 offline 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>