How do I refresh a page automatically

G

Gram

Is there another way to automatically refresh or reload a page, other than
using a meta refresh?
 
K

Kris

Gram said:
Is there another way to automatically refresh or reload a page, other than
using a meta refresh?

Explain the situation and we may be able to supply you with a good
solution.
 
G

Gram

I have a chat room made with ASP ( I know, there are better ways to do this)
and I am using an iframe to display the conversation text so far. So I have
a meta refresh to keep reloading the text at a regular interval, however, I
also have an anchor tag at the end of the text, so it will automatically
scroll to the bottom, but the meta refresh doesn't woork with the extra
#bottom bit.

<META HTTP-EQUIV='REFRESH' CONTENT='30;URL=conversation.asp#bottom'>

Any thoughts?
 
M

mscir

Gram said:
I have a chat room made with ASP ( I know, there are better ways to do this)
and I am using an iframe to display the conversation text so far. So I have
a meta refresh to keep reloading the text at a regular interval, however, I
also have an anchor tag at the end of the text, so it will automatically
scroll to the bottom, but the meta refresh doesn't woork with the extra
#bottom bit.

<META HTTP-EQUIV='REFRESH' CONTENT='30;URL=conversation.asp#bottom'>

Any thoughts?

Maybe try using Javascript to refresh the page.

this page has the iframe:

<html>
<head>
<script language="JavaScript" type="text/javascript">
function msgRefresh () {
window.frames['iframe1'].location = "2.html#bottom";
window.setTimeout('msgRefresh()',2000);
}
</script>
</head>

<body onload='msgRefresh()'>
test
<hr>
<iframe height="650" width="600" src="2.html" name="iframe1"
scrolling="yes">This browser does not support...</iframe>
<hr>
test
</body>
</html>



2.html, the page loaded into the iframe, includes:

<a name="bottom">&nbsp</a>

It seems to work on my ie6 and netscape 7.1

MIke
 
G

Gram

Thanks for the help Mike.

It seems to work grand refreshing the page, however it doesn't seem the like
the anchor (#bottom) part. When I have this part in, I can see the browser
try to reload, but the iframe doesn't change.
When I remove the #bottom, it works perfect, with out the scrolling of
course. Is there any way to keep them independant? to get a seperate
function to scroll it to the bottom?

Also, any ideas why a sumbit button doesn't sumbit when hitting the return
key?

Again, Thanks for the help,

Gram.

mscir said:
I have a chat room made with ASP ( I know, there are better ways to do this)
and I am using an iframe to display the conversation text so far. So I have
a meta refresh to keep reloading the text at a regular interval, however, I
also have an anchor tag at the end of the text, so it will automatically
scroll to the bottom, but the meta refresh doesn't woork with the extra
#bottom bit.

<META HTTP-EQUIV='REFRESH' CONTENT='30;URL=conversation.asp#bottom'>

Any thoughts?

Maybe try using Javascript to refresh the page.

this page has the iframe:

<html>
<head>
<script language="JavaScript" type="text/javascript">
function msgRefresh () {
window.frames['iframe1'].location = "2.html#bottom";
window.setTimeout('msgRefresh()',2000);
}
</script>
</head>

<body onload='msgRefresh()'>
test
<hr>
<iframe height="650" width="600" src="2.html" name="iframe1"
scrolling="yes">This browser does not support...</iframe>
<hr>
test
</body>
</html>



2.html, the page loaded into the iframe, includes:

<a name="bottom">&nbsp</a>

It seems to work on my ie6 and netscape 7.1

MIke
 
M

mscir

Gram said:
Thanks for the help Mike.

It seems to work grand refreshing the page, however it doesn't seem the like
the anchor (#bottom) part. When I have this part in, I can see the browser
try to reload, but the iframe doesn't change.
When I remove the #bottom, it works perfect, with out the scrolling of
course. Is there any way to keep them independant? to get a seperate
function to scroll it to the bottom?

Also, any ideas why a sumbit button doesn't sumbit when hitting the return
key?

How does this work?

<html>
<head>
<script type="text/javascript">
var milliSecondsToWait = 2000;
function reloadIFrame(){
window.frames['iframe1'].location = "2.html?" + (new Date().getTime());
window.frames['iframe1'].location.hash="#bottom"
myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
}
var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
</script>
</head>

<body onload='reloadIFrame()'>
test
<p>&nbsp;
<iframe height="450" width="600" src="2.html" name="iframe1"
scrolling="yes">This browser does not support...</iframe>
<p>&nbsp;
test
</body>
</html>
 
M

mscir

How does this work?
<html>
<head>
<script type="text/javascript">
var milliSecondsToWait = 2000;
function reloadIFrame(){
window.frames['iframe1'].location = "2.html?" + (new Date().getTime());
window.frames['iframe1'].location.hash="#bottom"
myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
}
var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
</script>
</head>

<body onload='reloadIFrame()'>
test
<p>&nbsp;
<iframe height="450" width="600" src="2.html" name="iframe1"
scrolling="yes">This browser does not support...</iframe>
<p>&nbsp;
test
</body>
</html>

Sorry, I made a mistake in the script cutting & pasting, should be:

<script type="text/javascript">
var milliSecondsToWait = 5000;
function reloadIFrame(){
window.frames['iframe1'].location = "2.html?" + (new Date().getTime());
window.frames['iframe1'].location.hash="#bottom"
myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
}
</script>
 
M

mscir

Gram, here's a simpler approach, don't know why I didn't think of it sooner:

in the <head> section of your page being loaded into the iframe:

<META HTTP-EQUIV='REFRESH' CONTENT='3; URL='4.htm';>
<script type="text/javascript">
function gotoanchor() {
this.location.hash='#bottom';
}
</script>
</head>


in the <body> section call the function:

<body onload="gotoanchor();">

Does this do it?
Mike
 
G

Gram

Thanks for all the help guys, I'll put it all into action shortly.
I'll be back if there are any problems. :0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top