multi iframe or div refresh

B

Bob

Hi All,

Is the following possible, and if so could someone show me some example code
please :eek:)

I have a web page with several iframes, and I want to be able to refresh
them only not the entire web page but also to refresh them at different time
intervals. I've tried a few ways but it ends up refreshing the entire page,
doh. I've tried with DIV's and objects aswell but no joy, I'm sure it must
be possible and I'm been a thicket ;o)

Any ideas?
Thanks in advance,
Rob
 
R

Randy Webb

Bob said the following on 5/1/2006 8:39 AM:
Hi All,

Is the following possible, and if so could someone show me some example code
please :eek:)

Is it possible for you not to post the same question twice in under 120
seconds?
I have a web page with several iframes, and I want to be able to refresh
them only not the entire web page but also to refresh them at different time
intervals. I've tried a few ways but it ends up refreshing the entire page,
doh. I've tried with DIV's and objects aswell but no joy, I'm sure it must
be possible and I'm been a thicket ;o)
window.frames['IFrameName'].reload()

Any ideas?

Yeah, lots of them. But most aren't fit for a family oriented NG.
 
B

Bob

Hi Randy,

Thanks for the quick response, trusty old outlook express went tits up
hence the double post :eek:)

I've tried the window.frames['IFrameName'].reload() but I'm getting a
javscript error of "object doesn't support this property or method".
I've enclosed a snippet of the code, could you be a star and point out the
error please :eek:)


======CODE======
<script language="JavaScript">
function refreshIt() {
window.frames['div2'].reload();
setTimeout('refreshIt()',5000); // refresh every 5 secs
}
</script>

<body onLoad="setTimeout('refreshIt()',5000);">
<iframe frameborder="0" scrolling="no" style="position: absolute; left:
0px; top: 00px;" id="div2" width="400" height="220"
src="CALLS.asp"></iframe>
</body>
======CODE======

Thanks in advance,
Rob

Randy Webb said:
Bob said the following on 5/1/2006 8:39 AM:
Hi All,

Is the following possible, and if so could someone show me some example
code
please :eek:)

Is it possible for you not to post the same question twice in under 120
seconds?
I have a web page with several iframes, and I want to be able to refresh
them only not the entire web page but also to refresh them at different
time
intervals. I've tried a few ways but it ends up refreshing the entire
page,
doh. I've tried with DIV's and objects aswell but no joy, I'm sure it
must
be possible and I'm been a thicket ;o)
window.frames['IFrameName'].reload()

Any ideas?

Yeah, lots of them. But most aren't fit for a family oriented NG.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/
 
R

Randy Webb

Bob said the following on 5/1/2006 9:04 AM:
Hi Randy,

Thanks for the quick response, trusty old outlook express went tits up
hence the double post :eek:)

Did OE go tits up and make you top post as well?

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
I've tried the window.frames['IFrameName'].reload() but I'm getting a
javscript error of "object doesn't support this property or method".
I've enclosed a snippet of the code, could you be a star and point out the
error please :eek:)


======CODE======
<script language="JavaScript">
function refreshIt() {
window.frames['div2'].reload();

window.frames['div2'].href = 'CALLS.asp?'+(new Date().getTime());
//just set its .href property, which will cause it to
//reload. You will need to add a parameter to insure
//it gets loaded from the server and not the cache
//That is what the new Date().getTime() is for.
setTimeout('refreshIt()',5000); // refresh every 5 secs
}

var myInterval = window.setInterval('refreshIt',5000);


The entire script block would look like this:

<script type="text/javascript">
function refreshIt(){
window.frames['div2'].href = 'CALLS.asp?'+(new Date().getTime());
}
var myInterval = window.setInterval(refreshIt,5000);
window.onload = refreshIt;
</script>

Notes:

1) Do not use the language attribute, use type instead.
2) window.setInterval(param1,param2). param1 is not quoted if it is a
function reference, and the () is not added.
3) You could do this without a named function. (I will leave that for
you to search/research before I tell you how if you want to know).

Using myInterval as above, you can stop the refresh by using
window.clearInterval(myInterval);
 
R

Richard Cornford

Randy Webb wrote:
window.frames['div2'].href = 'CALLS.asp?'+(new Date().getTime());
<snip>

It might be an idea to make that:-

window.frames['div2'].location.href = ...

- or some other variant that includes the - location - object.

Richard.
 
R

Randy Webb

Richard Cornford said the following on 5/1/2006 3:45 PM:
Randy Webb wrote:
window.frames['div2'].href = 'CALLS.asp?'+(new Date().getTime());
<snip>

It might be an idea to make that:-

window.frames['div2'].location.href = ...

- or some other variant that includes the - location - object.

When I first read your reply, my first thought was "Of course. Randy,
you are a dipstick". But I went back to my test file and re-tested it to
confirm that I did indeed check/test that code (and I did). And then I
started thinking about it and wondering - what browser does the code I
posted not work in? Latest release of that browser though.

I won't get into a "The specs say you should do this" discussion, but I
am curious where it doesn't work.

The only thing I changed in the code was adding a div to dump the href
into and kept posting it:

And then re-tested it in O7/8/9 (even though I specified the most recent
release of a browser), IE6, Firefox, Mozilla, they all worked fine.

<URL: http://members.aol.com/_ht_a/hikksnotathome/test/IFrameTest.html>

But yes, for historical and semantical reasons it should reference the
location object.
 
R

Richard Cornford

Randy said:
Richard Cornford said the following on 5/1/2006 3:45 PM:
Randy Webb wrote:
window.frames['div2'].href = 'CALLS.asp?'+(new Date().getTime());
<snip>

It might be an idea to make that:-

window.frames['div2'].location.href = ...

- or some other variant that includes the - location - object.

When I first read your reply, my first thought was "Of course.
Randy, you are a dipstick".

Give it time ;-)
But I went back to my test file and re-tested it to confirm
that I did indeed check/test that code (and I did). And then
I started thinking about it and wondering - what browser does
the code I posted not work in? Latest release of that browser
though.

Well there you have to decide what constitutes 'work' in this case. My
impression was that the intended outcome included the re-loading of the
contents of the IFRAME. In which case I would expect that if I selected
the text shown in the IFRAME the selection would disappear when the
frame re-loaded. I would also expect that if, while your test page was
running in a browser, I disconnected from the internet the next re-load
would show some sort of "unable to connect to server" report. Neither of
these expectations was satisfied by IE 6 or Mozilla 1.7.
I won't get into a "The specs say you should do this"
discussion,

That would be a rather futile discussion in connection to the -
location - object as it has never been subject to formal specification.
but I am curious where it doesn't work.

The only thing I changed in the code was adding a div to
dump the href into and kept posting it:

And then re-tested it in O7/8/9 (even though I specified
the most recent release of a browser), IE6, Firefox, Mozilla,
they all worked fine.

<URL:
http://members.aol.com/_ht_a/hikksnotathome/test/IFrameTest.html>

Your code initially creates, and then re-assigns values to, an - href -
property of a window object, it then reflects these values into the DIV.
All of this 'works', and can be expected to work in pretty much any
scriptable browser. What I would not expect is any re-loading of the
content of the window object to which the - href - property was added as
a side effect of the assignments, and I found no evidence that any
re-loading of the IFRAME was happening.
But yes, for historical and semantical reasons it should
reference the location object.

Effectiveness is probably an overriding reason for including the -
location - object in the operation.

Richard.
 

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

Top