Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection check 2

Status
Not open for further replies.

peacecodotnet

Programmer
May 17, 2004
123
0
0
US
Is there a way to tell with Javascript whether a user is online? Obviously this is going to be running on a page that is saved locally.

Any help would be greatly appreciated!

Peace out,
Peace Co.
 
If the page is run locally, what user are you wanting to check on? Surely not the person who opened the page? [smile]

-kaht

Do the chickens have large talons?
[banghead]
 
I modified my FAQ on how to get the dimensions of an image client-side, and came up with this neat trick:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		var tempImage;

		function checkOnlineStatus() {
			var tempImage = new Image();
			tempImage.onload = returnOnlineStatus;
			tempImage.onerror = returnOfflineStatus;
			tempImage.src = '[URL unfurl="true"]http://www.google.co.uk/intl/en_uk/images/logo.gif';[/URL]		// 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>

It has been tested working in IE 6, FF 1, NN 7.1 (both online and offline statuses).

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]
 

Blah. I had to disable my wireless connection to test this. The first time I've been offline since forever! ;o)

Dan
 
Heh, I misread the question. After seeing dan's repsonse it's so clear now :)

-kaht

Do the chickens have large talons?
[banghead]
 
Thanks so much for all your work! I never would've got this myself. Thanks again!

Peace out,
Peace Co.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top