Hi i have this script to auto refresh my webpage, it has a countdown timer.
My website is in 2 frames, and i only want the bottom frame to refresh but i want the timer in the top frame.
at the moment the code is in my top.php witch is the header frame, if i place in the index.php (main body frame) it doesnt work properly.
example http://devstudio.co.uk/
Is there a way of doing this?
thanks in advance for any help.
Tony-H
javascript
top.phpCode:<script language="JavaScript"> //configure refresh interval (in seconds) var countDownInterval=60; //configure width of displayed text, in px (applicable only in NS4) var c_reloadwidth=200 </script> <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer> <script> var countDownTime=countDownInterval+1; function countDown(){ countDownTime--; if (countDownTime <=0){ countDownTime=countDownInterval; clearTimeout(counter) window.location.reload() return } if (document.all) //if IE 4+ document.all.countDownText.innerText = countDownTime+" "; else if (document.getElementById) //else if NS6+ document.getElementById("countDownText").innerHTML=countDownTime+" " else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds') document.c_reload.document.c_reload2.document.close() } counter=setTimeout("countDown()", 1000); } function startit(){ if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds') countDown() } if (document.all||document.getElementById) startit() else window.onload=startit </script>
index.phpCode:<?php include("common.php"); ?> <html> <head> <title><?php echo $site_title ?></title> <script language="JavaScript"> //configure refresh interval (in seconds) var countDownInterval=10; //configure width of displayed text, in px (applicable only in NS4) var c_reloadwidth=200 </script> <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer> <script> var countDownTime=countDownInterval+1; function countDown(){ countDownTime--; if (countDownTime <=0){ countDownTime=countDownInterval; clearTimeout(counter) window.location.reload() return } if (document.all) //if IE 4+ document.all.countDownText.innerText = countDownTime+" "; else if (document.getElementById) //else if NS6+ document.getElementById("countDownText").innerHTML=countDownTime+" " else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds') document.c_reload.document.c_reload2.document.close() } counter=setTimeout("countDown()", 1000); } function startit(){ if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds') countDown() } if (document.all||document.getElementById) startit() else window.onload=startit </script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> </tr> <tr> <td valign="top" background="images/bg.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%" colspan="2" valign="top"><TABLE cellSpacing=0 cellPadding=0 width=770 border=0> <TBODY>MY HEADER </body> </html>
Code:<? srand((double)microtime()*1000000); function randString($l) { if($l==0) return ""; else return randChar().randString($l-1); } function randChar() { $str = "01234"; return substr($str, rand(0, strlen($str)-1), 1); } $random_number = randstring(1); if ($random_number=="0") {$site="http://www.partyspotters.com";} if ($random_number=="1") {$site="http://www.ukche.com";} if ($random_number=="2") {$site="http://www.partyspotters.com";} if ($random_number=="3") {$site="http://www.ukche.com";} if ($random_number=="4") {$site="http://www.ukche.com";} print <<<EOT <frameset rows="140,*" frameborder="NO" border="0" framespacing="0"> <frame src="top.php" name="topFrame" scrolling="NO" noresize > <frame src="$site" name="mainFrame"> </frameset> EOT; ?>


Reply With Quote


Bookmarks