Looking for a way to bring a self refreshing update page to the front, not against a users will, it's a service for my users. The page works as is but I need it to be the top window when it reloads (12,15 or 30 minutes).
Tried onload, onfocus onblur etc.. but none of them work in firefox which over 30% of my users have with the remaining bulk using IE.
The refresh code looks like this:
<html>
<head>
<title>ForexGuru UPDATE alert.</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:bold;
}
#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>
<center>
<font face=verdana size=2><b>
ForexGuru.co.uk
</b></font>
CONTENT HERE
<script type="text/javascript">
//Set number of days persistence for Cookie
var pDays=30
//NOTE: HTML allowed in Set Strings
//Put text all on one line
//Set String for select header:
var selHead="Set alert update frequency:<br>"
//Set String for Explanation of this setting to users:
var reExp="<br>Your choice will persist for "+pDays+" Days, cookies need to be active.<br>Clearing or resetting of cookies will reset the counter.<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.forexguru.co.uk 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.forexguru.co.uk 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="10">12 minutes</option>')
write('<option value="1440">24 minutes</option>')
write('<option value="1800">30 minutes</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>
</center>
</body>
</html>
So I just need a clever somebody who knows how to bring it to the front when it reloads. Alternatively to play a sound when it reloads IF I set a value to 1 and not play a sound if I set a value to 0. The user should be able to turn this feature off if they wish which will be stored in a cookie.
Anybody know what I'm on about ? lol
TIA Darren![]()



Reply With Quote

Bookmarks