0

Hey guys I'm having a little bit of an issue with this code, the code simply detects a page refresh, works fine in IE and FF, but it doesn't seem to be working in opera. Anyone got any suggestions on how to fix this? I've had an issue like this before but it didn't fix it, nor can I find anything on the net.

Thanks for any help :)

code:

<script language="JavaScript">
function checkRefresh()
{
	var today = new Date();
	var now = today.getUTCSeconds();

	var cookie = document.cookie;
	var cookieArray = cookie.split('; ');

	for(var loop=0; loop < cookieArray.length; loop++)
	{
		var nameValue = cookieArray[loop].split('=');
		if( nameValue[0].toString() == 'SHTS' )
		{
			var cookieTime = parseInt( nameValue[1] );
		}
		else if( nameValue[0].toString() == 'SHTSP' )
		{
			var cookieName = nameValue[1];
		}
	}

	if( cookieName &&
		cookieTime &&
		cookieName == escape(location.href) &&
		Math.abs(now - cookieTime) < 5 )
	{
	
	window.location = "index.php?end=yes"

	}	
}

function prepareForRefresh()
{
	if( refresh_prepare > 0 )
	{
		var today = new Date();
		var now = today.getUTCSeconds();
		document.cookie = 'SHTS=' + now + ';';
		document.cookie = 'SHTSP=' + escape(location.href) + ';';
	}
	else
	{
		document.cookie = 'SHTS=;';
		document.cookie = 'SHTSP=;';
	}
}

function disableRefreshDetection()
{
	refresh_prepare = 0;
	return true;
} 
var refresh_prepare = 1;
</script>


//And the body tag


<body id="home" onLoad="JavaScript:checkRefresh();"
onUnload="JavaScript:prepareForRefresh();">
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ello
0

Opera does not fire the onunload() event when a page is refreshed. I dont think there could be any solution to this as of now

0

Opera does not fire the onunload() event when a page is refreshed. I dont think there could be any solution to this as of now

Ahhh I didn't know that, it wont be a problem I wasn't planning on keeping it to run at onload, so it should be fine :)

Thanks for the help parry, appreciate it .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.