473,394 Members | 1,916 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,394 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 178923

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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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
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...

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.