473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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!

[HTML]<html>
<head>

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

</head>
<body>
<iframe id="iframe1" height="200" width="900"
src="http://google.com"></iframe>
<br>
<input type="button" value="Reload Original CSI Content" onclick="Reload();">

<iframe id="iframe2" height="200" width="900"
src="http://google.com"></iframe>
<br>
<input type="button" value="Reload Original CSI Content" onclick="Reload();">
</body>
</html>[/HTML]
Jan 25 '08 #1
2 12653
gits
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');
  3.  
  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

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

Similar topics

0
by: Martin | last post by:
I understand that as of IE5.5 iframes respect the z-index style property. However I have noticed some odd behaviour when the iframe's src is set to an MHT web archive instead of an HTML file. ...
2
by: nightstar | last post by:
I am creating a web page that will contain multiple Iframes. One of the Iframes will contain a bill of sale that is generated by a script on x.mydomain.com/somefile.php?someparameters. One of the...
0
by: Guadala Harry | last post by:
I have an aspx page that opens as a modal dialog. The aspx contains two IFrames (ID = thumbFrame and mainFrame). From the code-behind of the page that loads in mainFrame I want to cause the page...
1
by: user | last post by:
I have a parent aspx page with a few iframes. Each of the iframes show an aspx page with a datagrid whose rows all show editable entry fields at all times. The user can enter values into the parent...
1
by: knkk | last post by:
Hi, I have an iframe that fetches content from a different domain. This is my URL, which has an iframe that fetches content from another site careerbuilder.co.in (this is a partnership channel, so...
3
by: smartphreak | last post by:
not sure if this is the right forum but i will try explain myself. lets start by giving the code <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />...
4
by: raymon | last post by:
Hi, I have a page with two iframes that load content from another website. Only one of the iframes is shown at a time, depending on which tab the user is viewing. If user clicks on tab A, he will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.