473,500 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make Javascript update IFRAME SRC?

How can I make an onchange event update the src for an IFRAME? I would like
to do it without reloading the page, is this possible?

Dave
Jul 20 '05 #1
3 35016


Dave Anderson wrote:
How can I make an onchange event update the src for an IFRAME? I would like
to do it without reloading the page, is this possible?


<iframe name="iframeName" src="whatever.html"></iframe>

<select onchange="if (window.frames && window.frames.iframeName) {
window.frames.iframeName.location.href =
this.options[this.selectedIndex].value;
}">

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Bonjour à Martin Honnen <ma*******@yahoo.de> qui nous a écrit :
Dave Anderson wrote:
How can I make an onchange event update the src for an IFRAME? I
would like to do it without reloading the page, is this possible?


<iframe name="iframeName" src="whatever.html"></iframe>

<select onchange="if (window.frames && window.frames.iframeName) {
window.frames.iframeName.location.href =
this.options[this.selectedIndex].value;
}">


or:
<iframe id="iframeId" src="whatever.html"></iframe>

<select onchange="if (document.getElementById) {
document.getElementById('iframeId').src =
this.options[this.selectedIndex].value;
}">

--
Cordialement, Thierry ;-)

Jul 20 '05 #3
"Cenekemoi" <tb***************@harrysoftware.ENVELERcom> wrote in
message news:bv**********@news-reader4.wanadoo.fr...
<snip>
How can I make an onchange event update the src for an IFRAME? I
would like to do it without reloading the page, is this possible?


<iframe name="iframeName" src="whatever.html"></iframe>

<select onchange="if (window.frames && window.frames.iframeName) {
window.frames.iframeName.location.href =
this.options[this.selectedIndex].value;
}">


or:
<iframe id="iframeId" src="whatever.html"></iframe>

<select onchange="if (document.getElementById) {
document.getElementById('iframeId').src =
this.options[this.selectedIndex].value;
}">


No, Martin's formulation is the most cross-browsers code for the task
and will work on significantly more browsers than attempting to re-set
the SRC of an IDed IFRAME by assigning to its src property.

Richard.
Jul 20 '05 #4

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

Similar topics

7
10890
by: Lorenzo Vaina | last post by:
Can i get the content of an URL and put it in a variable using javascript? I want js execute different operations varying a file that is on internet. Thanks, regards.
2
2766
by: dh | last post by:
How can a button that resides on the Main page tell the child Iframes to redirect without the page posting back? I keep getting a javascript error: "frames.iframe1 is null or not an object." I'm...
10
2187
by: Simon | last post by:
Hi, Sorry for the cross posting, but I think it applies to both languages. As we all know, JavaScript is client side and php is server side, (the php code is 'allowed' to do stuff on the...
4
5926
by: sameergn | last post by:
Hi, I have HTML form whose target is an invisible IFrame. After the IFrame is loaded completely, following code transfers contents of IFrame to DIV ...
10
2413
by: jason_box | last post by:
Hello, I was wondering if there was a way to have a javacript be activated by an input button that would call to a cgi program and querey every 10minutes and the cgi would update the page without...
4
2083
by: Laphan | last post by:
Hi The god that is Martin Honnen gave me a great tip to DOM/JS some HTML data into an iframe, but I need to make sure that the iframe is ready to take it before I paste it in. At the moment,...
15
2227
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private)...
3
5348
by: lolo | last post by:
hello. happy new year. I'm trying to build a website for my wife and she is adament on having a horizontal thumbnail scrolling div. great. I have a good vertical scrolling thing, but can't...
2
3131
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
0
7136
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
7235
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...
1
6909
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
7397
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
5491
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
4614
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1431
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
317
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.