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. http://devstudio.co.uk/ Is there a way of doing this? thanks in advance for any help. javascript <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> Code (markup): top.php << with javescript code in <?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 (markup): index.php << The frame i want to refresh <frameset rows="140,*" frameborder="NO" border="0" framespacing="0"> <frame src="top.php" name="topFrame" scrolling="NO" noresize > <frame src="$site" name="mainFrame"> </frameset> Code (markup):
hmm i kinda got it working, but sometimes the syncing with refresh and timer is out any idea how to sync the refresh? this is tottally baffling my brain, and the way its coded right now is very messy, lol i dont no who im talking to, just hoping somebodys listening lol my 3 files now are <?php include("common.php"); ?> <html> <head> <title><?php echo $site_title ?></title> <script language="JavaScript"> //configure refresh interval (in seconds) var countDownInterval=20; //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> <body> </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 (markup): index.php <frameset rows="140,*" frameborder="NO" border="0" framespacing="0"> <frame src="top.php" name="topFrame" scrolling="NO" noresize > <frame src="bottom.php" name="mainFrame"> </frameset> Code (markup): bottom.php <META HTTP-EQUIV="Refresh" CONTENT="20;"> <? 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.google.com";} if ($random_number=="3") {$site="http://www.yahoo.com";} if ($random_number=="4") {$site="http://www.msn.com";} print <<<EOT <frameset " frameborder="NO" border="0" framespacing="0"> <frame src="$site" name="mainFrame"> </frameset> EOT; ?> Code (markup):
see here, how to refresh/reload part of the page using frames. http://www.techtricky.com/how-to-refresh-page-or-part-of-the-page-automatically/