PDA

View Full Version : How To Setup Auto Refresh That Can Be Turned On And Off



Wizebize
11-17-2005, 11:07 PM
Hi guys ... I currently use an AUTO REFRESH feature on my stocktriggers.com (stock trading) website that works fanstastic. HOWEVER, I would like to setup a script that allows users to either TURN OFF / TURN ON, or manually ADJUST the auto refresh time within their browsers. Right now my main forum page auto refreshes every 60 seconds, and I can adjust it to whatever time I set on my end. But they have no control over it on their end ... and those with slower connections to the internet want the browser to refresh perhaps every 2 minutes, or every 5 minutes, for example. And some don't want the feature to be on at all, and prefer to refresh when they feel like. But at least half of my members like the current auto refresh feature the way it is now. So I would like to set it up so that everyone has an option to adjust the REFRESH TIME and / or TURN IT OFF AND ON on their end as they please.

Let me know if there is a solution out there. I have searched everywhere on the net and can't seem to find an answer.

Thanks, Wize

jscheuer1
11-18-2005, 05:44 AM
Hopefully, someone who knows how to write proper cookie code will come along and offer suggestions as to how to improve this (or, if you are in a learning mood check here (http://www.quirksmode.org/js/cookies.html) ) but, this is the basic idea (it may interfere with other cookies and/or be frustrated by other cookies on the page):


<script type="text/javascript">
var reIt

function doit(){
if (window.location.reload)
window.location.reload( true );
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}

function startUp(){
if (unescape(document.cookie).split(';')[1])
reIt=setTimeout("doit()", unescape(document.cookie).split(';')[1])
else
reIt=setTimeout("doit()", 60000)
}

function setRe(val){
clearTimeout(reIt)
if (val==0){
document.cookie=''
return;
}
else
document.cookie=val*1000
startUp();
}

onload=startUp
</script>


<span>set refresh rate:</span>
<input type="button" value="1 Minute" onclick="setRe(60);">
<input type="button" value="2 Minute" onclick="setRe(120);">
<input type="button" value="5 Minute" onclick="setRe(300);">
<input type="button" value="No Refresh" onclick="setRe(0);"> <span>Default is 1 Minute</span>

Works here in local trials in FF and IE. It is a session only cookie and so, must be set each browser session. It applies to the page it is on only.

Wizebize
11-18-2005, 06:12 PM
Hi John ... I like the script, and it works ... HOWEVER, my test webpage is jumping all over the places as if the script is running full time, in a loop or whatever. Also the TITLE BAR is flashing data as if it's refreshing constantly, etc. even though it does refresh only at the time interval set. I'm not sure what the cause is.

The script I am currently using is the AUTO REFRESH script from Dynamic Drive. I love it, it works perfectly. But it would be awesome to be able to turn that script on and off as desired, and / or give the user the ability to adjust the refresh interval within their own browser, rather than me controlling it on my end. I have it set for 60 second refreshes but many members wish to turn it off from time to time, or adjust it to refresh every two minutes, or five minutes, etc.

Thanks much, Wize

jscheuer1
11-18-2005, 07:40 PM
Did you take the other script off of your page first before testing? Also, I couldn't be sure if I found the DD script you are talking about:

whatever
.

Wizebize
11-18-2005, 07:56 PM
Hi John ... yes, I tested it on a blank web page first and it reacted strangely, although it did work. So I didnt incorporate into my website.

Here's the script I am currently using: http://www.dynamicdrive.com/dynamicindex6/refresh.htm

Here's where I was testing the script you posted earlier:
http://www.stocktriggers.com/set_refresh_rate.htm

I recently built a script to HIDE / VIEW the members on my website at any given time, and it works great. But I was also hoping to build a script that allows REFRESH options on the user-end, and I can't seem to get exactly what I need.

Thanks for your help!!

Wize

jscheuer1
11-18-2005, 08:31 PM
Well, your demo works fine here. Perhaps, on your end, it is suffering from what I mentioned about interaction with other cookies from your site/page(s) already in effect. I took my own advice and studied the info on cookies. I've worked out a more robust version that will persist for one week (persistence length is configurable as a comment in the code documents). It will also be in effect for all pages on your site that have this script on it, and should not interact with other established cookies:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>User's Choice Refresh Rate - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<script type="text/javascript">

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name)
{
createCookie(name,"",-1);
}


var reIt

function doit(){
if (window.location.reload)
window.location.reload( true );
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}

function startUp(){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
if (readCookie('resetInt')!=null)
reIt=setTimeout("doit()", readCookie('resetInt'))
else
return;
}

function setRe(val){
clearTimeout(reIt)
if (val==0){
eraseCookie('resetInt')
return;
}
else
// 7 in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();
}

onload=startUp;

</script>
<span>Set refresh rate:</span>
<input type="button" value="1 Minute" onclick="setRe(60);">
<input type="button" value="2 Minute" onclick="setRe(120);">
<input type="button" value="5 Minute" onclick="setRe(300);">
<input type="button" value="No Refresh" onclick="setRe(0);"><span><sub>(default)</sub><br>Your choice will persist site wide for 1 week unless changed or you clear your browser's cookies.</span>
</body>
</html>

Wizebize
11-18-2005, 09:20 PM
Awesome thanks ... much better!! I think the other script was reacting to the godaddy.com server or something, because it was on a blank page when tested, but it was reacting oddly. But this new script works great. I just need to see if I can incorporate a TIMER into it so users have a count-down on display before the next refresh occurs. I also want to convert this to a "drop down box" type of options instead of buttons, to take up less space on the page. If you know how to do that quickly ... let me know. Thanks again ... great stuff John.

Wize

jscheuer1
11-18-2005, 10:46 PM
I think I got all that, the neat part is that the cookie will also set the select box to the currently active refresh interval, you can test that by setting it with the previous version then opening this one (for a local demo, both pages may need to be in the same directory, if live, the effect should be sitewide for pages with this script and markup on them:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name)
{
createCookie(name,"",-1);
}


var reIt, countRe

function doit(){
if (window.location.reload)
window.location.reload( true );
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}

function startUp(){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
clearInterval(countRe)
if (readCookie('resetInt')!=null){
document.getElementById('reCounter').innerHTML=readCookie('resetInt')/1000
var opts=document.getElementById('selRe').options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval("document.getElementById('reCounter').innerHTML=parseInt(document.getElementById('reCounter').innerHTML, 10)-1", 1000)
reIt=setTimeout("doit()", readCookie('resetInt'))
}
else
return;
}

function setRe(val){
clearTimeout(reIt)
if (val==0){
clearInterval(countRe)
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled</b>'
eraseCookie('resetInt')
return;
}
else
// 7 (or the last value) in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();
}

onload=startUp;

</script>
</head>
<body>

<span>Set refresh rate:</span><br>
<select id="selRe" onchange="setRe(this.options[selectedIndex].value)">
<option value="0" selected>No Refresh</option>
<option value="60">1 Minute</option>
<option value="120">2 Minute</option>
<option value="300">5 Minute</option>
</select>
<span><br>Your choice will persist site wide on pages with the above select box<br>for 1 week unless changed or you clear your browser's cookies.<br>There are <span id="reCounter"><b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled</b></span> seconds left to refresh.</span>

</body>
</html>

jscheuer1
11-19-2005, 08:01 AM
As sometimes happens, I got quite carried away with this one. You may prefer my version posted just before this post. It has almost all the functionality of this version but is in a much rougher form that might be easier to highly customize, though this version should be easier to just slip in wherever you want it and has the advantage of leaving no footprint on the page if javascript is disabled and should work in older IE versions:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">

/* Begin Styles for User's Select Refresh Rate w/counter */

#reCounter b { /* Set Style for 'Refresh Disabled' Message */
color:red;
background-color:white;
font-weight:normal;
}
#refreshCounter { /* Set these two styles for Select Refresh Counter Container */
border-collapse:collapse;
border:1px solid black;
font-family:tahoma,verdana,arial,sans-serif;
font-size:.9em;
}
#refreshCounter td {
padding:10px;
}
#preCount { /* These three Styles should remain unchanged */
visibility:hidden;
}
#preC, #sufC {
display:none;
}

/* End Styles for User's Select Refresh Rate w/counter */

</style>
</head>
<body>
<script type="text/javascript">

/*User's Select Refresh Rate w/counter - script
John Davenport Scheuer as first seen in
http://www.dynamicdrive.com/forums
under user name: jscheuer1
This credit must remain on your page
for legal use */

//Set number of days persistence for Cookie
var pDays=7

//NOTE: HTML allowed in Set Strings
//Put text all on one line

//Set String for select header:
var selHead="Set Page Refresh Frequency:<br>"

//Set String for Explanation of this setting to users:
var reExp="<br>Your choice will persist for "+pDays+" Days, site wide, on pages displaying the<br>above select box, unless changed or you clear your browser's cookies.<br>"

//Set String for Refresh Disabled:
var reDis="Refresh Disabled"

//Set String for counter prefix text:
var prefixC="There are"

//Set String for counter suffix text:
var suffixC="seconds left until page refresh."

/////////////////////Stop Editing Script///////////////////

//Begin http://www.quirksmode.org Cookie Code:

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name)
{
createCookie(name,"",-1);
}

//End http://www.quirksmode.org Cookie Code

var reIt, countRe, reCounter, text1, text2, opt

function doit(){
if (window.location.reload)
window.location.reload( true );
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}

function startUp(){
text1=document.getElementById? document.getElementById('preC').style : document.all['preC'].style
text2=document.getElementById? document.getElementById('sufC').style : document.all['sufC'].style
clearInterval(countRe)
if (readCookie('resetInt')!=null){
opt=(readCookie('resetInt')/1000).toString(10).length
text1.display=text2.display='inline'
reCounter=document.getElementById? document.getElementById('reCounter') : document.all['reCounter']
reCounter.innerHTML=padTo(readCookie('resetInt')/1000)
var opts=document.getElementById? document.getElementById('selRe').options : document.all['selRe'].options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval("reCounter.innerHTML=padTo(parseInt(reCounter.innerHTML, 10)-1)", 1000)
reIt=setTimeout("doit()", readCookie('resetInt'))
}
else
return;
}

function padTo(val){
var val=val.toString(10)
var preCount=document.getElementById? document.getElementById('preCount') : document.all['preCount']
preCount.innerHTML=val.length==1&&opt==3? '00' : (val.length==2&&opt==3)||(val.length==1&&opt==2)? '0' : ''
return val
}

function setRe(val){
clearTimeout(reIt)
if (val==0){
text1.display=text2.display='none'
clearInterval(countRe)
reCounter.innerHTML='<b>'+reDis+'</b>'
eraseCookie('resetInt')
return;
}
createCookie('resetInt', val*1000, pDays)
startUp();
}

onload=startUp;

with (document){
write('<table id="refreshCounter"><tr><td><span>'+selHead+'</span>')
write('<select id="selRe" onchange="setRe(options[selectedIndex].value)">')
write('<option value="0" selected>No Refresh</option>')
write('<option value="60">1 Minute</option>')
write('<option value="120">2 Minute</option>')
write('<option value="300">5 Minute</option>')
write('</select>')
write('<span>'+reExp+'<span id="preC">'+prefixC+' </span><span id="preCount"></span><span id="reCounter"><b>'+reDis+'</b></span><span id="sufC"> '+suffixC+'</span></span>')
write('</td></tr></table>')
}

</script>
</body>
</html>

jamesd2
10-12-2010, 05:08 PM
I have a question: How do I change the default value of that script jscheuer1 posted? For example, when I enter the page, I'd like the script to start refreshing the page automatically every minute (without selecting it from the drop-down menu).

I've already tried to do this

<option value="60" selected>1 Minute</option>
but it doesn't work.

Thanks for any help!

jscheuer1
10-14-2010, 05:04 AM
<!DOCTYPE html>
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

/* Begin Styles for User's Select Refresh Rate w/counter */

#reCounter b { /* Set Style for 'Refresh Disabled' Message */
color: red;
background-color: white;
font-weight: normal;
}
#refreshCounter { /* Set these two styles for Select Refresh Counter Container */
border-collapse: collapse;
border: 1px solid black;
font-family: sans-serif;
font-size: .9em;
}
#refreshCounter td {
padding: 10px;
}
#preCount { /* These three Styles should remain unchanged */
visibility: hidden;
}
#preC, #sufC {
display: none;
}

/* End Styles for User's Select Refresh Rate w/counter */

</style>
</head>
<body>
<script type="text/javascript">
/*User's Select Refresh Rate w/counter - script
(c) John Davenport Scheuer as first seen in
http://www.dynamicdrive.com/forums
under user name: jscheuer1
This credit must remain on your page
for legal use */
(function(){

//Set number of days persistence for Cookie
var pDays=7;

//NOTE: HTML allowed in Set Strings
//Put text all on one line

//Set String for select header:
var selHead="Set Page Refresh Frequency:<br>";

//Set String for Explanation of this setting to users:
var reExp="<br>The selected choice will persist for " + pDays + " Days, site wide, on pages displaying the<br>above select box, unless changed or you clear your browser's cookies.<br>";

//Set String for Refresh Disabled:
var reDis="Refresh Disabled";

//Set String for counter prefix text:
var prefixC="There are";

//Set String for counter suffix text:
var suffixC="seconds left until page refresh."

///////////////////// Stop Editing Script ///////////////////

//Begin http://www.quirksmode.org Cookie Code:

function createCookie(name,value,days){
if (days){
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++){
var c = ca[i];
while (c.charAt(0)==' ') {c = c.substring(1,c.length);}
if (c.indexOf(nameEQ) == 0) {return c.substring(nameEQ.length,c.length);}
}
return null;
}

function eraseCookie(name){
createCookie(name, "" , -1);
}

//End http://www.quirksmode.org Cookie Code

var reIt, countRe, reCounter, text1, text2, opt;

function doit(){
if (window.location.reload){
window.location.reload( true );
} else if (window.location.replace){
window.location.replace(unescape(location.href));
} else {
window.location.href=unescape(location.href);
}
}

function startUp(){
text1=document.getElementById? document.getElementById('preC').style : document.all['preC'].style;
text2=document.getElementById? document.getElementById('sufC').style : document.all['sufC'].style;
clearInterval(countRe);
if (readCookie('resetInt')!=null){
if (readCookie('resetInt')==='no'){
return;
}
opt=(readCookie('resetInt')/1000).toString(10).length;
text1.display=text2.display='inline';
reCounter=document.getElementById? document.getElementById('reCounter') : document.all['reCounter'];
reCounter.innerHTML=padTo(readCookie('resetInt')/1000);
var opts=document.getElementById? document.getElementById('selRe').options : document.all['selRe'].options;
for (var i_tem = 0; i_tem < opts.length; i_tem++){
if (opts[i_tem].value==readCookie('resetInt')/1000){
opts.selectedIndex=i_tem;
}
}
countRe=setInterval(function(){reCounter.innerHTML=padTo(parseInt(reCounter.innerHTML, 10)-1);}, 1000);
reIt=setTimeout(doit, readCookie('resetInt'));
} else {
document.getElementById('selRe').options.selectedIndex = 1;
setRe(document.getElementById('selRe').options[1].value);
}
}

function padTo(val){
var val=val.toString(10),
preCount=document.getElementById? document.getElementById('preCount') : document.all['preCount'];
preCount.innerHTML=val.length==1&&opt==3? '00' : (val.length==2&&opt==3)||(val.length==1&&opt==2)? '0' : '';
return val;
}

function setRe(val){
val = document.getElementById('selRe').value;
clearTimeout(reIt);
if (val==0){
text1.display=text2.display='none';
clearInterval(countRe);
reCounter.innerHTML='<b>'+reDis+'</b>';
createCookie('resetInt', 'no', pDays);
return;
}
createCookie('resetInt', val*1000, pDays);
startUp();
}

if (window.addEventListener){
window.addEventListener('load', function(){
startUp();
document.getElementById('selRe').addEventListener('change', setRe, false);
}, false);
}
else if (window.attachEvent){
window.attachEvent('onload', function(){
startUp();
document.getElementById('selRe').attachEvent('onchange', setRe);
});
}

with (document){
write('<table id="refreshCounter"><tr><td><span>'+selHead+'</span>');
write('<select id="selRe">');
write('<option value="0" selected>No Refresh</option>');
write('<option value="60">1 Minute</option>');
write('<option value="120">2 Minute</option>');
write('<option value="300">5 Minute</option>');
write('</select>');
write('<span>'+reExp+'<span id="preC">'+prefixC+' </span><span id="preCount"></span><span id="reCounter"><b>'+reDis+'</b></span><span id="sufC"> '+suffixC+'</span></span>');
write('</td></tr></table>');
}
})();

</script>
</body>
</html>

jamesd2
10-14-2010, 04:19 PM
Thank you very much! Really appreciate this!!

sharteel
07-08-2011, 01:31 PM
Hi John,

Thank you for this great script.

I have a demand for you.


Currently, we can to choose the timerefresh with list (select from). See below your code.




with (document){
write('<table id="refreshCounter"><tr><td><span>'+selHead+'</span>');
write('<select id="selRe">');
write('<option value="0" selected>No Refresh</option>');
write('<option value="60">1 Minute</option>');
write('<option value="120">2 Minute</option>');
write('<option value="300">5 Minute</option>');
write('</select>');
write('<span>'+reExp+'<span id="preC">'+prefixC+' </span><span id="preCount"></span><span id="reCounter"><b>'+reDis+'</b></span><span id="sufC"> '+suffixC+'</span></span>');
write('</td></tr></table>');
}
})();




Is-it possible to see and select only ON | OFF word mode instead of html select form ?

The ON mode is running with 10 Minutes refresh.

Best regards.

S.T

jscheuer1
07-08-2011, 02:32 PM
with (document){
write('<table id="refreshCounter"><tr><td><span>'+selHead+'</span>');
write('<select id="selRe" size="2">');
write('<option value="0" selected>Off</option>');
write('<option value="600">On</option>');
write('</select>');
write('<span>'+reExp+'<span id="preC">'+prefixC+' </span><span id="preCount"></span><span id="reCounter"><b>'+reDis+'</b></span><span id="sufC"> '+suffixC+'</span></span>');
write('</td></tr></table>');
}
})();

sharteel
07-08-2011, 03:02 PM
Hi john,

Ty but i think my explanation is not good.

With a picture is more easy.

With ON & OFF button / word.

Best regards.

jscheuer1
07-08-2011, 07:02 PM
How about:


<!DOCTYPE html>
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

/* Begin Styles for User's Select Refresh Rate w/counter */

#reCounter b { /* Set Style for 'Refresh Disabled' Message */
color: red;
background-color: white;
font-weight: normal;
}
#refreshCounter { /* Set these two styles for Select Refresh Counter Container */
border-collapse: collapse;
border: 1px solid black;
font-family: sans-serif;
font-size: .9em;
}
#refreshCounter td {
padding: 10px;
}
#preCount { /* These three Styles should remain unchanged */
visibility: hidden;
}
#preC, #sufC, #selRe {
display: none;
}

/* End Styles for User's Select Refresh Rate w/counter */

</style>
</head>
<body>
<script type="text/javascript">
/*User's Select Refresh Rate w/counter - script
(c) John Davenport Scheuer as first seen in
http://www.dynamicdrive.com/forums
under user name: jscheuer1
This credit must remain on your page
for legal use */
(function(){

//Set number of days persistence for Cookie
var pDays=7;

//Text Color for active button:
var activeColor = '#a00';

//Underline Style for active button:
var activeUnderline = 'underline';

//NOTE: HTML allowed in Set Strings
//Put text all on one line

//Set String for select header:
var selHead="Set Page Refresh Option: ";

//Set String for Explanation of this setting to users:
var reExp="<br>The selected choice will persist for " + pDays + " Days, site wide, on pages displaying the<br>above buttons, unless changed by you or you clear your browser's cookies.<br>";

//Set String for Refresh Disabled:
var reDis="Refresh Disabled";

//Set String for counter prefix text:
var prefixC="There are";

//Set String for counter suffix text:
var suffixC="seconds left until page refresh.";

///////////////////// Stop Editing Script ///////////////////

//Begin http://www.quirksmode.org Cookie Code:

function createCookie(name,value,days){
if (days){
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++){
var c = ca[i];
while (c.charAt(0)==' ') {c = c.substring(1,c.length);}
if (c.indexOf(nameEQ) == 0) {return c.substring(nameEQ.length,c.length);}
}
return null;
}

function eraseCookie(name){
createCookie(name, "" , -1);
}

//End http://www.quirksmode.org Cookie Code

var reIt, countRe, reCounter, text1, text2, opt, opts, ipts;

function doit(){
if (window.location.reload){
window.location.reload( true );
} else if (window.location.replace){
window.location.replace(unescape(location.href));
} else {
window.location.href=unescape(location.href);
}
}

function startUp(){
ipts = document.getElementById('refreshCounter').getElementsByTagName('input');
text1=document.getElementById? document.getElementById('preC').style : document.all['preC'].style;
text2=document.getElementById? document.getElementById('sufC').style : document.all['sufC'].style;
opts=document.getElementById? document.getElementById('selRe').options : document.all['selRe'].options;
for (var i = ipts.length - 1; i > -1; --i){
ipts[i].onclick = (function(i){
return function(){
if(opts.selectedIndex !== i){
opts.selectedIndex = i;
setRe();
ipts[Math.abs(i - 1)].style.textDecoration = '';
ipts[Math.abs(i - 1)].style.color = '';
this.style.textDecoration = activeUnderline;
this.style.color = activeColor;
}
};
})(i);
}
clearInterval(countRe);
if (readCookie('resetInt')!=null){
if (readCookie('resetInt')==='no'){
ipts[1].style.textDecoration = activeUnderline;
ipts[1].style.color = activeColor;
ipts[1].focus();
return;
}
opt=(readCookie('resetInt')/1000).toString(10).length;
text1.display=text2.display='inline';
reCounter=document.getElementById? document.getElementById('reCounter') : document.all['reCounter'];
reCounter.innerHTML=padTo(readCookie('resetInt')/1000);
for (var i_tem = 0; i_tem < opts.length; i_tem++){
if (opts[i_tem].value==readCookie('resetInt')/1000){
opts.selectedIndex=i_tem;
ipts[i_tem].style.textDecoration = activeUnderline;
ipts[i_tem].style.color = activeColor;
ipts[i_tem].focus();
text1.innerHTML = text1.innerHTML;
}
}
countRe=setInterval(function(){reCounter.innerHTML=padTo(parseInt(reCounter.innerHTML, 10)-1);}, 1000);
reIt=setTimeout(doit, readCookie('resetInt'));
} else {
document.getElementById('selRe').options.selectedIndex = 1;
ipts[1].style.textDecoration = activeUnderline;
ipts[1].style.color = activeColor;
ipts[1].focus();
text1.innerHTML = text1.innerHTML;
setRe(document.getElementById('selRe').options[1].value);
}
}

function padTo(val){
var val=val.toString(10),
preCount=document.getElementById? document.getElementById('preCount') : document.all['preCount'];
preCount.innerHTML=val.length==1&&opt==3? '00' : (val.length==2&&opt==3)||(val.length==1&&opt==2)? '0' : '';
return val;
}

function setRe(val){
val = document.getElementById('selRe').value;
clearTimeout(reIt);
if (val==0){
text1.display=text2.display='none';
clearInterval(countRe);
reCounter.innerHTML='<b>'+reDis+'</b>';
createCookie('resetInt', 'no', pDays);
return;
}
createCookie('resetInt', val*1000, pDays);
startUp();
}

if (window.addEventListener){
window.addEventListener('load', function(){
startUp();
document.getElementById('selRe').addEventListener('change', setRe, false);
}, false);
}
else if (window.attachEvent){
window.attachEvent('onload', function(){
startUp();
document.getElementById('selRe').attachEvent('onchange', setRe);
});
}

with (document){
write('<table id="refreshCounter"><tr><td><span>'+selHead+'</span>');
write('<input type="button" value="On"> <input type="button" value="Off">');
write('<select id="selRe" size="2">');
write('<option value="600">On</option>');
write('<option value="0" selected>Off</option>');
write('</select>');
write('<span>'+reExp+'<span id="preC">'+prefixC+' </span><span id="preCount"></span><span id="reCounter"><b>'+reDis+'</b></span><span id="sufC"> '+suffixC+'</span></span>');
write('</td></tr></table>');
}
})();

</script>
</body>
</html>

sharteel
07-13-2011, 01:56 PM
Ty John :)

Aloxa
12-01-2011, 11:11 PM
Hi, jscheuer1 , thanks for the script it is very useful
One question: How to make the script to auto refresh the page only ones for each visitor after specific time, so will refresh the page after about 10 sec. and no more until the history is deleted.
Thanks Mina

jscheuer1
12-02-2011, 01:28 AM
The script can't know when or if the user deletes their browser's history.

We can (and the script already does) set a cookie. This cookie could persist until the browser is closed, or for a specified number of days. The page could set the cookie and refresh once after the specified time. As long as the cookie is present, no further refreshing would take place.

Would you want a counter for that - while it is counting down to the one refresh, or not?

Aloxa
12-02-2011, 03:57 PM
Script: Auto Refresh
http://www.dynamicdrive.com/forums/showthread.php?t=6141

Hi John, i find your script for auto refresh, what code should i use to autore fresh the page only ones for each visitor, so when the visitor come to the page will refresh one time and no mode refreshing. i really need this
Thank you very much




Hopefully, someone who knows how to write proper cookie code will come along and offer suggestions as to how to improve this (or, if you are in a learning mood check here (http://www.quirksmode.org/js/cookies.html) ) but, this is the basic idea (it may interfere with other cookies and/or be frustrated by other cookies on the page):


<script type="text/javascript">
var reIt

function doit(){
if (window.location.reload)
window.location.reload( true );
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}

function startUp(){
if (unescape(document.cookie).split(';')[1])
reIt=setTimeout("doit()", unescape(document.cookie).split(';')[1])
else
reIt=setTimeout("doit()", 60000)
}

function setRe(val){
clearTimeout(reIt)
if (val==0){
document.cookie=''
return;
}
else
document.cookie=val*1000
startUp();
}

onload=startUp
</script>


<span>set refresh rate:</span>
<input type="button" value="1 Minute" onclick="setRe(60);">
<input type="button" value="2 Minute" onclick="setRe(120);">
<input type="button" value="5 Minute" onclick="setRe(300);">
<input type="button" value="No Refresh" onclick="setRe(0);"> <span>Default is 1 Minute</span>

Works here in local trials in FF and IE. It is a session only cookie and so, must be set each browser session. It applies to the page it is on only.

sharteel
01-31-2012, 01:38 PM
Hi,

If u want no button form, you can add some style in the code:



write('
<input type="button" style="border: none; background-color: transparent;" value="ON">
<input type="button" style="border: none; background-color: transparent;" value="OFF">
')


I have tested with: FF 9.0.1 and IE 7.0.5730.13

Regards,

S.T

sharteel
02-01-2012, 06:10 PM
Hi John,

I put the js script at the bottom of page and the browser (all) scroll down the page, automatically when i load the page.

How can we avoid (fix) this?

Regards,

S.T

jscheuer1
02-02-2012, 12:56 AM
Please post a link to the page on your site that contains the problematic code so we can check it out.

jscheuer1
02-07-2013, 02:06 PM
There are several versions of this script in this thread and now you've modified one of them. Please include your full code, or better yet:

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

Dahls
02-07-2013, 03:37 PM
Updated to code v001
Try making Pause Continue and Update Page buttons and separate the status text for better display.
Also changed code as described in Previous thread for browser to remember position if page was scrolled
For now it shows
Buttons for Pause, Continue and for Manual update

when set to No refresh
Refresh disabled
After Pause button is pressed
Auto update stopped
And when counter runs it only shows the seconds
xxx

Need to know where to add the text There are, and seconds left to refresh.


<div>
<script type="text/javascript">
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
var reIt, countRe
function doit(){
if (window.location.reload)
window.location.reload();
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}
function startUp(){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
clearInterval(countRe)
if (readCookie('resetInt')!=null){
document.getElementById ('reCounter').innerHTML=readCookie('resetInt')/1000
var opts=document.getElementById('selRe').options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval("document.getElementById('reCounter').innerHTML=parseInt(document.getElementById('reCounter').innerHTML, 10)-1", 1000)
reIt=setTimeout("doit()", readCookie('resetInt'))
}
else
return;
}
function setRe(val){
clearTimeout(reIt)
if (val==0){
clearInterval(countRe)
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled.</b>'
eraseCookie('resetInt')
return;
}
else
// 7 (or the last value) in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();

}
onload=startUp;
function stopTimer() {
clearTimeout(countRe)
clearTimeout(reIt)
document.getElementById('reCounter').innerHTML='Auto update Paused. Note the visible timer resets when Pause is clicked, then if Continiue is clicked, system will count down from where it left.'
}
</script>
</head>
<body>
<select id="selRe" onchange="setRe(this.options[selectedIndex].value)">
<option value="0" selected>No Refresh</option>
write('<option value="10">10 Seconds</option>')
write('<option value="20">20 Seconds</option>')
write('<option value="30">30 Seconds</option>')
write('<option value="40">40 Seconds</option>')
write('<option value="50">50 Seconds</option>')
write('<option value="60">&nbsp;&nbsp;1 Minute</option>')
write('<option value="120">&nbsp;&nbsp;2 Minute</option>')
write('<option value="300">&nbsp;&nbsp;5 Minute</option>')
</select>
<input type="button" name="clearTime" value="Pause" onClick="stopTimer()">
<input type="button" value="Continue" onClick="startUp()">
<input type="button" value="Update Page" onClick="window.location.reload()">
<span><br>&nbsp;<span id="reCounter"></span></span>
<hr>
</div>

jscheuer1
02-07-2013, 04:27 PM
Access is determined by the forum's settings and cannot be overridden by the moderators. I think after a few more posts you shouldn't have this problem. But then again, because the settings that determine who gets moderated and who doesn't are multi-layered and come from at least two programs, I cannot be certain.

I'm looking at your code now.

jscheuer1
02-07-2013, 05:10 PM
<!DOCTYPE html>
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

/* Begin Styles for User's Select Refresh Rate w/counter */

#reCounter b { /* Set Style for 'Refresh Disabled' Message */
color: red;
background-color: white;
font-weight: normal;
}
#refreshCounter { /* Set these two styles for Select Refresh Counter Container */
border-collapse: collapse;
border: 1px solid black;
font-family: sans-serif;
font-size: .9em;
}
#refreshCounter td {
padding: 10px;
}
#preCount { /* These three Styles should remain unchanged */
visibility: hidden;
}
#preC, #sufC {
display: none;
}

/* End Styles for User's Select Refresh Rate w/counter */

</style>
</head>
<body>
<script type="text/javascript">
/*User's Select Refresh Rate w/counter - script
(c) John Davenport Scheuer as first seen in
http://www.dynamicdrive.com/forums
under user name: jscheuer1
This credit must remain on your page
for legal use */



function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
var reIt, countRe
function doit(){
if (window.location.reload)
window.location.reload();
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}
function startUp(saved){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
clearInterval(countRe)
if (readCookie('resetInt')!=null){
var prefix = 'There are ', suffix = ' seconds left until page refresh.', counter = saved === true && startUp.saved? startUp.saved : readCookie('resetInt')/1000;
document.getElementById ('reCounter').innerHTML= prefix + counter + suffix;
var opts=document.getElementById('selRe').options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval(function(){
document.getElementById('reCounter').innerHTML= prefix + (--counter) + suffix;
startUp.saved = counter;
}, 1000)
reIt=setTimeout("doit()", (counter - (saved === true && startUp.saved? 1 : 0)) * 1000)
}
else
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled</b>'
return;
}
function setRe(val){
clearTimeout(reIt)
if (val==0){
clearInterval(countRe)
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled</b>'
eraseCookie('resetInt')
return;
}
else
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">There are</b>'
// 7 (or the last value) in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();
}
onload=startUp;

function stopTimer() {
if(document.getElementById('selRe').value == 0){return;}
clearTimeout(countRe)
clearTimeout(reIt)
document.getElementById('reCounter').innerHTML='Auto update Paused. If Continiue is clicked, system will count down from where it left.'
}
</script>
</head>
<body>
<select id="selRe" onchange="setRe(this.options[selectedIndex].value)">
<option value="0" selected>No Refresh</option>
write('<option value="10">10 Seconds</option>')
write('<option value="20">20 Seconds</option>')
write('<option value="30">30 Seconds</option>')
write('<option value="40">40 Seconds</option>')
write('<option value="50">50 Seconds</option>')
write('<option value="60">&nbsp;&nbsp;1 Minute</option>')
write('<option value="120">&nbsp;&nbsp;2 Minute</option>')
write('<option value="300">&nbsp;&nbsp;5 Minute</option>')
</select>
<input type="button" name="clearTime" value="Pause" onClick="stopTimer()">
<input type="button" value="Continue" onClick="startUp(true)">
<input type="button" value="Update Page" onClick="window.location.reload()">
<span><br>&nbsp;<span id="reCounter"></span></span>
<hr>
</div>
</body>
</html>

Dahls
02-07-2013, 10:15 PM
ok made testpage (http://home.comcast.net/~jscheuer1/side/refresh/dahls-h.htm)
and here is complete code.

still problem cant get the text around the seconds in place,without it mixes with the two other messages


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
var reIt, countRe
function doit(){
if (window.location.reload)
window.location.reload();
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}
function startUp(){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
clearInterval(countRe)
if (readCookie('resetInt')!=null){
document.getElementById ('reCounter').innerHTML=readCookie('resetInt')/1000
var opts=document.getElementById('selRe').options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval("document.getElementById('reCounter').innerHTML=parseInt(document.getElementById('reCounter').innerHTML, 10)-1", 1000)
reIt=setTimeout("doit()", readCookie('resetInt'))

}
else
return;
}
function setRe(val){
clearTimeout(reIt)
if (val==0){
clearInterval(countRe)
document.getElementById('reCounter').innerHTML='<b style="color:red;background-color:white;font-weight:normal;">Refresh Disabled.</b>'
eraseCookie('resetInt')
return;
}
else
// 7 (or the last value) in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();
}
onload=startUp;
function stopTimer() {
clearTimeout(countRe)
clearTimeout(reIt)
document.getElementById('reCounter').innerHTML='Auto update Paused. Note the visible timer resets when Pause is clicked, then if Continiue is clicked, system will count down from where it left.'
}
</script>
</head>
<body>
<div>
<select id="selRe" onchange="setRe(this.options[selectedIndex].value)">
<option value="0" selected>No Refresh</option>
write('<option value="10">10 Seconds</option>')
write('<option value="20">20 Seconds</option>')
write('<option value="30">30 Seconds</option>')
write('<option value="40">40 Seconds</option>')
write('<option value="50">50 Seconds</option>')
write('<option value="60">&nbsp;&nbsp;1 Minute</option>')
write('<option value="120">&nbsp;&nbsp;2 Minute</option>')
write('<option value="300">&nbsp;&nbsp;5 Minute</option>')
</select>
<input type="button" name="clearTime" value="Pause" onClick="stopTimer()">
<input type="button" value="Continue" onClick="startUp()">
<input type="button" value="Update Page" onClick="window.location.reload()">
<span><br>&nbsp;<span id="reCounter"></span></span>
<hr>
</div>
</body>
</html>

jscheuer1
02-07-2013, 10:39 PM
http://home.comcast.net/~jscheuer1/side/refresh/dahls-h.htm

Dahls
02-07-2013, 10:54 PM
thank you changed it to your link :)

Dahls
02-08-2013, 08:13 AM
Wow! you solved it all thank you :)

Dahls
02-09-2013, 11:47 AM
problem with scroll position after reload in explore tested in IE 8 and 10
in my old code i changed
changed

window.location.reload( true );
to

window.location.reload();
and it remembers the pages position if it has been scrolled.
guese it was not right, just tested and it is not working.

is there some way telling the stupid internet explore to go to same position after reload
script works fine in Firefox and Chrome.

jscheuer1
02-09-2013, 04:10 PM
http://home.comcast.net/~jscheuer1/side/refresh/dahls-2-h.htm

Dahls
02-09-2013, 09:51 PM
http://home.comcast.net/~jscheuer1/side/refresh/dahls-2-h.htm
link is not working.

jscheuer1
02-10-2013, 04:02 AM
Yes, there's some problem with the server. If it persists I will have to contact my ISP. For now though, I can give you the full code to that page:


<!DOCTYPE html>
<html>
<head>
<title>User's Select Refresh Rate w/counter - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

/* Begin Styles for User's Select Refresh Rate w/counter */

#reCounter { /* Set Style for counter Message */
font-family: sans-serif;
font-size: 90%;
}
#reCounter b { /* Set Style for 'Refresh Disabled' Message */
color: red;
background-color: white;
font-weight: normal;
}
#reCounter span { /* style for number shown in seconds left string */
text-align: right;
width: 1.75em;
display: inline-block;
font: normal 110% consolas, 'courrier new', monospace;
}
#reCounter span.digits2 { /* style for number shown in seconds left string when refresh rate is under 100 seconds */
width: 1.25em;
}
#refreshCounter { /* Set these two styles for Select Refresh Counter Container */
border-collapse: collapse;
border: 1px solid black;
font-family: sans-serif;
font-size: 90%;
}
#refreshCounter td {
padding: 10px;
}
#preCount { /* These three Styles should remain unchanged */
visibility: hidden;
}
#preC, #sufC {
display: none;
}

/* End Styles for User's Select Refresh Rate w/counter */

</style>
</head>
<body>
<select id="selRe">
<option value="0" selected>No Refresh</option>
<option value="10">10 Seconds</option>
<option value="20">20 Seconds</option>
<option value="30">30 Seconds</option>
<option value="40">40 Seconds</option>
<option value="50">50 Seconds</option>
<option value="60">&nbsp;&nbsp;1 Minute</option>
<option value="120">&nbsp;&nbsp;2 Minute</option>
<option value="300">&nbsp;&nbsp;5 Minute</option>
</select>
<input type="button" id="pause" name="clearTime" value="Pause">
<input type="button" id="continue" value="Continue">
<input type="button" id="update" value="Update Page">
<span><br>&nbsp;<span id="reCounter"></span></span>
<hr>
<script type="text/javascript">
/*User's Select Refresh Rate w/counter - script
(c) John Davenport Scheuer as first seen in
http://www.dynamicdrive.com/forums
under user name: jscheuer1
This credit must remain on your page
for legal use */

(function(){
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
var ie = /MSIE (\d+)/.exec(navigator.userAgent); ie = ie && ie[1];
var reIt, countRe, prefix = 'There are <span>', suffix = '</span> seconds left until page refresh.',
refreshdisabled = '<b>Refresh Disabled</b>',
regex = [/ class="digits2"/, /span/], recounter = document.getElementById('reCounter');
function doit(){
recounter.innerHTML= prefix + '0' + suffix;
if(ie){
createCookie('iescroll', document.documentElement.scrollLeft + 'and' + document.documentElement.scrollTop);
}
setTimeout(function(){
if (window.location.reload)
window.location.reload();
else if (window.location.replace)
window.location.replace(unescape(location.href))
else
window.location.href=unescape(location.href)
}, 300);
}
function startUp(saved){
// uncomment below line for testing only
//alert(readCookie('resetInt'))
clearInterval(countRe);
var cookval = readCookie('resetInt'), iescroll = readCookie('iescroll');
if (cookval!=null){//console.log(cookval);
prefix = prefix.replace(regex[0], '');
prefix = cookval/1000 < 100? prefix.replace(regex[1], 'span class="digits2"') : prefix;
var counter = saved === true && startUp.saved? startUp.saved : cookval/1000;
document.getElementById ('reCounter').innerHTML= prefix + counter + suffix;
var opts=document.getElementById('selRe').options
for (var i_tem = 0; i_tem < opts.length; i_tem++)
if (opts[i_tem].value==readCookie('resetInt')/1000)
opts.selectedIndex=i_tem
countRe=setInterval(function(){
recounter.innerHTML= prefix + (--counter) + suffix;
startUp.saved = counter;
}, 1000)
reIt=setTimeout(doit, counter * 1000);
if(ie && iescroll){
eraseCookie('iescroll');
//alert(iescroll);
iescroll = iescroll.split('and');
attachEvent('onload', function(){window.scrollTo(iescroll[0], iescroll[1]);});
}
}
else
recounter.innerHTML=refreshdisabled;
return;
}
function setRe(val){
clearTimeout(reIt)
if (val==0){
clearInterval(countRe)
recounter.innerHTML=refreshdisabled;
eraseCookie('resetInt')
return;
}
else
// 7 (or the last value) in the below line is the number of days persistence
createCookie('resetInt', val*1000, 7)
startUp();
}
onload=startUp;

function stopTimer() {
if(document.getElementById('selRe').value == 0){return;}
clearTimeout(countRe)
clearTimeout(reIt)
recounter.innerHTML='Auto update Paused. If Continiue is clicked, system will count down from where it left.'
}
document.getElementById('selRe').onchange=function(){setRe(this.value);};
document.getElementById('pause').onclick=stopTimer;
document.getElementById('continue').onclick=function(){startUp(true);};
document.getElementById('update').onclick=doit;
})();
</script>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
Hi
</body>
</html>

Oh, and it looks like the server is back now. Try the link again.

OOps, looks like it was only back for a little bit, now it's down again.

Dahls
02-10-2013, 12:04 PM
so happy for your work,
works fine in IE 10

edited and deleted the other post. had forgot remove all old code before pasting the new one :o

jscheuer1
02-10-2013, 02:56 PM
Doubtful. Look at the code and the markup from my post. Unlike before where the script is in the head of the page and events are hard coded into the markup, with this latest version the script is the last thing before </body> tag and the events are assigned by the script according to the ids of the elements in the markup. If you use this same or similar structure on your page it should be fine.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.