OZONE Asylum
Forums
DHTML/Javascript
Javascript Online Checker (Am i online or offline)
This page's ID:
28659
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Here's some code I wrote a few years back to use the "onload" and "onerror" events of the Image object: [code]<html> <head> <script type="text/javascript"> <!-- var tempImage; function checkOnlineStatus() { var tempImage = new Image(); tempImage.onload = returnOnlineStatus; tempImage.onerror = returnOfflineStatus; tempImage.src = 'http://www.google.co.uk/intl/en_uk/images/logo.gif'; // this must point to the url of a valid image } function returnOnlineStatus() { document.getElementById('onlineStatus').firstChild.nodeValue = 'You are currently online.'; } function returnOfflineStatus() { document.getElementById('onlineStatus').firstChild.nodeValue = 'You are currently offline.'; } //--> </script> </head> <body onload="checkOnlineStatus();"> <div id="onlineStatus">Checking online status, please wait...</div> </body> </html>[/code] Any known image URL is good - I just happened to use Google's. Dan
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »