471,888 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,888 software developers and data experts.

reload iframe for individual and all iframes on page

I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh all of them - from the server (this could be on page refresh also) as the purpose is to reset the iframe to the original content in case the user clicked on a link in that iframe and changed it, but also in case there were updates to the original page since the last load. The page hosting the iframes is in a frameset.

I used the following code from an older thread but (as I don't know javascript) when I modified it to include two iframes for a test it didn't work. It refloads only the first iframe when clicking either button. Reloading the whole page doesn't reload the iframes if they have been changed, and I need that (again, from the server), too.

This needs to be manual reloading as the info in the iframe may be in use at any moment and I can't have it vanish unexpectedly even for a few seconds.

Also, is there any way to block break out of frames code for an iframe?

Your help is much appreciated!


<script type="text/javascript">
function Reload () {
var f = document.getElementById('iframe1','iframe2');
f.src = f.src;

<iframe id="iframe1" height="200" width="900"
<input type="button" value="Reload Original CSI Content" onclick="Reload();">

<iframe id="iframe2" height="200" width="900"
<input type="button" value="Reload Original CSI Content" onclick="Reload();">
Jan 25 '08 #1
2 12037
5,390 Expert Mod 4TB
hi ...

use something like the following instead. this will reload all iframes in your page.

Expand|Select|Wrap|Line Numbers
  1. function reload_iframes() {
  2.     var f_list = document.getElementsByTagName('iframe');
  4.     for (var i = 0, f; f = f_list[i]; i++) {
  5.         f.src = f.src;
  6.     }
  7. }
kind regards
Jan 25 '08 #2
I tried what you suggested, pasting it in the head section and it didnt reload the iframes when I used the browser reload button. I did different search terms in the google.com iframes and expected that the original blank would be reloaded in both iframes, but it came back with the same two pages of search results. What am I missing?

Again, I would especially like a button that would reload all the iframes on the page from the server, and without reloading the page itself.

Also, if you know a way to block break out of frames for iframes, this has been a problem with the page. Alternately, to disable javascript in pages in iframes only.
Jan 26 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Martin | last post: by
2 posts views Thread by nightstar | last post: by
1 post views Thread by knkk | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.