473,441 Members | 1,778 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,441 software developers and data experts.

Refresh iframe

How do I refresh an iframe via JavaScript from the parent page?

/Jacob

Mar 15 '06 #1
5 178930

Jacob wrote:
How do I refresh an iframe via JavaScript from the parent page?

/Jacob


<html>
<head>
<script type="text/javascript">

function Reload () {
var f = document.getElementById('iframe1');
f.src = f.src;
}

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

Mar 15 '06 #2
Is there no way to use location.refresh or location.reload?

/Jacob

Mar 15 '06 #3

Jacob wrote:
Is there no way to use location.refresh or location.reload?

/Jacob


var f = document.getElementById('iframe1');
f.contentWindow.location.reload(true);

Value of parameter in the brackets :

false - Default. Reloads the page from the browser cache.
true - Reloads the page from the server.

But I don't know whether it works elsewere besides IE.

Mar 15 '06 #4
Jacob wrote:
How do I refresh an iframe via JavaScript from the parent page?


window.frames[...].reload(...);

Might not be pretty, is completely proprietary, but it works always.
Even with different second-level domains.
PointedEars
Mar 16 '06 #5
marss wrote:
Jacob wrote:
Is there no way to use location.refresh or location.reload?


var f = document.getElementById('iframe1');
f.contentWindow.location.reload(true);

Value of parameter in the brackets :

false - Default. Reloads the page from the browser cache.
true - Reloads the page from the server.

But I don't know whether it works elsewere besides IE.


It also works in Gecko, in fact the Location object and its reload()
method (along with the meaning of the argument) were introduced in
NN 3.0 (JavaScript 1.0 then). However, this solution has its
shortcomings:

- it requires implementation of HTMLDocument::getElementById()
(not before IE 5.0)
- it requires an ID for the `iframe' element,
(or implementation of HTMLDocument::getElementsByTagName();
not before IE 5.0)
- it requires support of the `contentWindow' property
(not before IE 5.5)

DOM Level 0 suffices here, works _always_ and most certainly _everywhere_
(except if client-side script support is unavailable).
PointedEars
Mar 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Conax | last post by:
Hi, It's me again asking about IFRAME. With UncleWobby, Steven Burn and Roland Hall's help, I was able to create a proper IFRAME section on my page. Now I come to the next problem. I'd...
0
by: nick | last post by:
In the following link, the screen has a lot of refresh (iframe keep relocate its position ) when the mouse hover around the popup menu. But IE doesn't have the problem. ...
2
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
21
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
0
by: Abhishek Srivastava | last post by:
Hello Everyone, I have two files. File 1 is called HTMLPage.html. The content of this file is <html><head><meta http-equiv='refresh' content='1'...
1
by: spolsky | last post by:
hi, i have the following pages. when form submitted with the field1 value is "ok" then the iframe must be loaded with the text "Page loaded...". This works fine with IE 6 and FireFox(1.5) but...
1
by: epower | last post by:
Hello, I am working on an ASP .NET application in Visual Studio 2005 and running IE7. This application has a page that contains an iframe which loads an .aspx page and hyperlinks that...
1
by: bnashenas1984 | last post by:
Hi everyone I'v seen several websites doing what I'm asking now but I don't know how they do it. Lets say we have an E-commerce website that has a shopping cart inside an IFrame which shows what...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.