Click to See Complete Forum and Search --> : How to force iframe to refresh?


Amo_Lin
01-07-2003, 08:23 PM
By running the following code, i couldn't see the web page change in my Iframe. why? how to add a statement in this script to force the Iframe to refresh?



function refreshInnerFrame()
{
for (i=1;i<10;i++)
{
document.frames(myInnerFrame).location=i+".html";
}
}


<iframe name="myInnerFrame" id="innerframe" src="1.html" iframe>


<input type=Checkbox onclick="refreshInnerFrame()">

Amo_Lin
01-07-2003, 10:06 PM
thank you for you reply;

I have changed the script accordingly, but i still couldn't see the change. I think there should be insert some time lag statemnet in to "for ..." statement of this script to have the browser to have time to response . am i right? please give me a guide.

thank you!

Amo

Amo_Lin
01-07-2003, 11:14 PM
Originally posted by Dave Clark
Possible.

window.setTimeout("self.frames.myInnerFrame.location.reload(true)", 1000);

Set the delay to whatever works best (1000 = 1 second).

Dave


Where should I Put "window.setTimeout("self.frames.myInnerFrame.location.reload(true)", 1000);" in to my script?

How do i delay 10 seconds before next cycle step?

I think the following is not right.

function automatic()
{
for (i=1;i<10;i++)
{
document.frames("myInnerFrame").location.href= i+".html";
setTimeout("document.frames('myInnerFrame').location.reload(true)",5000);
}

}


Best regards
Amo

gil davis
01-08-2003, 07:58 AM
Maybe something like this:

function changeIt(fl) {
document.frames["myInnerFrame"].location.href=fl;
}

function automatic() {
for (i=1;i<10;i++) {
setTimeout("changeIt(" + i + ".html)", i * 5000);
}
}
This should key up 10 file loads spread out over 5 second intervals. As long as it doesn't take 5 seconds to load the file, it ought to work.

Amo_Lin
01-08-2003, 06:14 PM
Originally posted by gil davis
Maybe something like this:

function changeIt(fl) {
document.frames["myInnerFrame"].location.href=fl;
alert(fl);

}

function automatic() {
for (i=1;i<10;i++) {
setTimeout("changeIt(" + i + ".html)", i * 5000);
}
}
This should key up 10 file loads spread out over 5 second intervals. As long as it doesn't take 5 seconds to load the file, it ought to work.


Thank you!
I add alert(fl); in the finction changeIt(fl);
but I only get alert msgbox "10.html"
I want code that automatically displays a new document, in the IFRAME, every specified seconds?

thank you again!

Amo_Lin
01-08-2003, 08:01 PM
Originally posted by Dave Clark
How about this:

function automatic(nbr, max, delay) {
if (nbr <= max) {
document.frames["myInnerFrame"].location.href = nbr + ".html";
}
if (nbr < max) {
setTimeout("automatic("+(nbr++)","+max+","+delay+")", delay);
}
}

Then, call it like this:

automatic(1, 10, 10000);

Dave


I added your code into my page, change "+(nbr++)" to
"+(nbr++)+", add a alert(nbr + ".html") in this code, I find the alert msg is always "1.html". why ?

I just want the code automatically displays a new document, in the IFRAME, every specified period.

Thank you any help.

function automatic(nbr, max, delay) {
if (nbr <= max) {
document.frames["myframe"].location.href = nbr + ".html";
document.frames["myframe"].location.reload;
alert(nbr + ".html");
}
if (nbr < max) {
setTimeout("automatic("+(nbr++)+","+max+","+delay+")", delay);
}
}

Amo_Lin
01-08-2003, 10:20 PM
Thank you, Dave Clark,thank you for your many valuble advice. I have learned more from your input.

But i still have a questions, the sample code you give here is
just refresh the Iframe with the same period, but how do I
refresh the Iframe with the Time information specified in corrent Iframe page? i tried but I get wrong result. please see
the comment in the code.

Thank you.


function automatic(nbr, max, delay) {
if (nbr <= max) {
***document.frames["myInnerFrame"].location.href = nbr + ".html";
var delayInfor=eval(document.frames["myInnerFrame"].document.getElementByID("delayInfor").value;
alert(delayInfor);

/* HRER the "delayInfor" is not the information of iframe page just changed(marked with '***'). it 's value is iframe's last page's delay information. what really I want is to use delay informaton of current ifrmae's page to control current delay time.*/
}
if (nbr < max) {
setTimeout("automatic("+(nbr++)+","+max+","+delay+")", delay);
}
}

Amo_Lin
01-08-2003, 11:27 PM
so many thanks to you!

For I=1 to 10000
thank you!
next


I am very glad to find a such a good site to disscuss Javascript and meet so many good tutors.

when my knowledge enough, I will try my best to help others.