Thank you so much it works!
I got it to work using this code:
Code:
<html>
<head>
<script language="JavaScript"> <!--
function checkRefresh()
{
// Get the time now and convert to UTC seconds
var today = new Date();
var now = today.getUTCSeconds();
// Get the cookie
var cookie = document.cookie;
var cookieArray = cookie.split('; ');
// Parse the cookies: get the stored time
for(var loop=0; loop < cookieArray.length; loop++)
{
var nameValue = cookieArray[loop].split('=');
// Get the cookie time stamp
if( nameValue[0].toString() == 'SHTS' )
{
var cookieTime = parseInt( nameValue[1] );
}
// Get the cookie page
else if( nameValue[0].toString() == 'SHTSP' )
{
var cookieName = nameValue[1];
}
}
if( cookieName &&
cookieTime &&
cookieName == escape(location.href) &&
Math.abs(now - cookieTime) < 5 )
{
// Refresh detected
// Insert code here representing what to do on
// a refresh
window.location = "http://www.regameit.com"
// If you would like to toggle so this refresh code
// is executed on every OTHER refresh, then
// uncomment the following line
// refresh_prepare = 0;
}
// You may want to add code in an else here special
// for fresh page loads
}
function prepareForRefresh()
{
if( refresh_prepare > 0 )
{
// Turn refresh detection on so that if this
// page gets quickly loaded, we know it's a refresh
var today = new Date();
var now = today.getUTCSeconds();
document.cookie = 'SHTS=' + now + ';';
document.cookie = 'SHTSP=' + escape(location.href) + ';';
}
else
{
// Refresh detection has been disabled
document.cookie = 'SHTS=;';
document.cookie = 'SHTSP=;';
}
}
function disableRefreshDetection()
{
// The next page will look like a refresh but it actually
// won't be, so turn refresh detection off.
refresh_prepare = 0;
// Also return true so this can be placed in onSubmits
// without fear of any problems.
return true;
}
// By default, turn refresh detection on
var refresh_prepare = 1;
-->
</script>
</head>
<body onLoad="JavaScript:checkRefresh();" onUnload="JavaScript:prepareForRefresh();">
<!-- The above is all that is needed. -->
<!-- Below is an example of the use of disableRefreshDetection()
to prevent false refreshes from being detected when forms
are submitted back to this page. If your web page does
not use forms that post back to themselves, then the
below does not matter to you. Omit it. -->
</body>
</html>
How would I ad a message to this asking the user if they are sure they want to refresh? such as:
Code:
<script type = "text/javascript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit() {
if (needToConfirm) {
return "You have attempted to refresh or leave this page. All ad data will be reset and you will have to restart the posting process in order for your ad to publish correctly.";
}
}
</script>
But I have had no luck getting the two codes to work together