Refreshing the browser window

bfeddish
bfeddish used Ask the Experts™
on
I have a regular ASP page (not ASP.NET) and I wan't to continuously refresh the page without having to hit a submit button or anything. I need something like the timer in ASP. NET.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can accomplish this using a meta tag.

<HTML>
<HEAD>
<META HTTP-EQUIV="refresh" content="2;URL=http://www.yoursite.com/newpage.htm">
<TITLE>Page has moved</TITLE>
</HEAD>
<BODY>
whatever you want to write
</BODY>
</HTML>


http://www.pageresource.com/html/metref.htm
bfeddish,

you can juse this tag with the rest of your META tags and it will refresh the whole page.  Otherwise you can mix your ASP page with a little Javascript that will do only a field.  Change the 30 to however many seconds you need before the page refreshes.

<meta http-equiv="Refresh" content="30">

Good luck,
Shayne
Commented:
Or javascript:

<SCRIPT LANGUAGE="Javascript"><!--
var oInterval="";
var iCounter = 5

oInterval=window.setInterval("Timer()",1000);
function Timer(){
  if (iCounter>0){
    iCounter=iCounter-1;
  }
  if (iCounter==0){
    window.clearInterval(oInterval);
    document.location.reload();
  }
}            

//--></SCRIPT>

Author

Commented:

I liked Nighman's the best but the others look useful too.  I upped the points and split them for everybody.

Thanks!
There's really no point in using setInterval though, as the interval clears when the page reloads.

The most compatible way of doing it would be something like this;

<script language="JavaScript" type="text/javascript">
<!--
setTimeout('document.location.assign(location.href)',5000);
//-->
</script>

That one is supported by all JavaScript enabled browsers.
5000 is the time in milliseconds before the action is triggered; 5 seconds.

If you still prefer setInterval this will be enough;

<script language="JavaScript1.2" type="text/javascript">
<!--
setInterval('document.location.reload()',5000);
//-->
</script>


FYI  ;)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial