473,399 Members | 3,401 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,399 software developers and data experts.

Mozilla - Changing iFrame source

I am having problems with changing a frames source file for Mozilla
(1.5.0.4). The followig code works for IE:

<script type="text/javascript">
var imgP = new Image();
function ShowPic(ShowThis, wdth, hght) {
imgP.src = "../pics/' + ShowThis + '"
xw = 500;
yh = 500*(hght/wdth);
window.document.getElementById("graphic").innerHTM L = '<img src="../
pics/' + ShowThis + '" width="' + xw + '" height="' + yh +
'"border="0">';

}
function ChangeList(oSel) {
window.document.getElementById("F1").src = oSel;
}
</script>

....
....
....

<div id="graphic">
<script>ShowPic("company_name.gif", 1255, 324)</script>
</div>
<p align="center">&nbsp;</p>
<td valign="bottom" width="17>
<img border="0" src="../images/
coner_right_top.gif" width="17" height="130">
</tr>
<tr>
<td class="blank" height="17" width="17</td>
<td class="blank" height="17" align="right"
width="527">
<img border="0" src="../images/
coner_right_bottom.gif" width="180" height="17"></td>
<td class="blank" height="17" width="17">
<img border="0" src="../images/coner_right.gif"
width="17" height="17></td>
</tr>
</table</td>
</tr>
<tr>
<td width="100%">
<p style="margin-bottom: 0; margin-top:0"
align="center">

<select size="1" name="D1"
onChange="ChangeList(this.options[ this.selectedIndex].value);" >
<option selected value="PlayList2.htm">September
2003</option>
<option value="PlayList1.htm">Urban Bistro X-Mas
Dinner</option>
</select></p>

<p style="margin-top: 0; margin-bottom: 0">
<iframe name="I1" id="F1" width="549" height="189"
src="PlayList2.htm">
Your browser does not support or is currently
configured not to display inline frames</iframe>
<p align="center" style="margin-top: 0; margin-bottom:
0">
....
....
....

Within the function:
function ChangeList(oSel) {
window.document.getElementById("F1").src = oSel;
}

I have tried
frames["I1"]
getElementsByName("I1")
.innerHTML
.src

but to no success. I do not think I can depend on the Java console to
help debug, because it indicates that
"window.document.getElementById("graphic").innerHT ML" has no
properties, when the ShowPic function antually works (it is called by
the clickable graphics in the iFrame).

Any help would be appreciated!

- Jon

Mar 19 '07 #1
3 7321
bu******@lycos.com said the following on 3/18/2007 11:52 PM:
I am having problems with changing a frames source file for Mozilla
(1.5.0.4). The followig code works for IE:
<snip>
Within the function:
function ChangeList(oSel) {
window.document.getElementById("F1").src = oSel;
}

I have tried
frames["I1"]
getElementsByName("I1")
.innerHTML
.src
You don't set an IFrame's src, innerHTML, you set it's location.href
property.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 19 '07 #2
ASM
bu******@lycos.com a écrit :
I am having problems with changing a frames source file for Mozilla
(1.5.0.4). The followig code works for IE:
but it is not the right code to use ...

parent.myIframe.location = 'newImage.jpg';
(needs the iFrame has a NAME (not an ID), here : 'myIframe' )

or with DOM

document.getElementById('F1').location = 'newImage.jpg';

function ChangeList(oSel) {
document.getElementById('F1').location = oSel;
// or :
// parent.frames['I1'].location = oSel;
}

It would has been simpler to have iframe's name same as iframe's id

I do not understand at all why you need a function so complicated
to display an image ...
var imgP = new Image();
function ShowPic(ShowThis, wdth, hght) {
imgP.src = "../pics/' + ShowThis + '"
xw = 500;
yh = 500*(hght/wdth);
window.document.getElementById("graphic").innerHTM L = '<img src="../
pics/' + ShowThis + '" width="' + xw + '" height="' + yh +
'"border="0">';
}

<style type="text/css">
#graphic { text-align: center; }
#graphic img { width: 500px; border: 0; }
</style>
<div id="graphic">
<img src="compagny_name.gif" alt="compagny logo" title="My compagny">
</div>
Variante (without css) :

<script type="text/javascript">
function ShowPic(ShowThis, wdth, where) {
where = document.getElementById(where);
where.src = ShowThis;
where.style.width = wdth+'px';
}
</script>
<div id="graphic" style="text-align:center">
<img src="" id="logo" alt="compagny logo" title="My compagny">
<script type="text/javascript">
ShowPic("company_name.gif", 500, 'logo');
</script>
</div>
<div id="graphic">
<script>ShowPic("company_name.gif", 1255, 324)</script>
</div>
[...]
<select size="1" name="D1"
onChange="ChangeList(this.options[ this.selectedIndex].value);" >
<option selected value="PlayList2.htm">September
2003</option>
<option value="PlayList1.htm">Urban Bistro X-Mas
Dinner</option>
</select></p>

<p style="margin-top: 0; margin-bottom: 0">
<iframe name="I1" id="F1" width="549" height="189"
src="PlayList2.htm">
Your browser does not support or is currently
configured not to display inline frames</iframe>
<p align="center" style="margin-top: 0; margin-bottom:
0">


but to no success. I do not think I can depend on the Java console to
help debug,
JavaScript console
because it indicates that
"window.document.getElementById("graphic").innerHT ML" has no
properties,
right because 'graphic' is not in the iFrame
('window' here is the iframe)
when the ShowPic function antually works (it is called by
the clickable graphics in the iFrame).
so you try to reach 'graphic' in main page, no ?
probably :
parent.document.getElementById("graphic").innerHTM L
could do what you expect

but if you call the function ShowPic(blah)
*from the iFrame* you must do :

parent.ShowPic(blah);


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 19 '07 #3
On Mar 19, 6:22 am, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
parent.myIframe.location = 'newImage.jpg';
(needs the iFrame has a NAME (not an ID), here : 'myIframe' )

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date- Hide quoted text -

- Show quoted text -

Thanks! The parent.<frame name>.location worked perfectly in both
Firefix and IE

- Jon

Mar 19 '07 #4

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

Similar topics

2
by: Peter | last post by:
Hello, First of all, sorry for all the code. I don't know how to explain my problem without it. I have a javascript function which can build a webpage dynamically. A striped down version of...
12
by: Justin Koivisto | last post by:
I am having a problem with Internet Explorer and javascript on a WYSIWYG editor I am creating. It all works in Mozilla, but IE returns flase for queryCommandEnabled('forecol'). JS isn't my strong...
2
by: swathi | last post by:
----------------------------------------------------------------------- A poll associated with this post was created, to vote and see th results, please visit...
2
by: apchar | last post by:
I have a simple ad rotator that's driving mozilla and netscape a little crazy. You know that symbol in the upper right corner of the browser that animates while a page is downloading and is...
6
by: Randell D. | last post by:
Folks, I've spent the past hour or so testing IFRAME with Mozilla 1.7.5 and not getting it to work - Then... I thought I'd try it in IE, and my code worked... Thus... is IFRAME an IE only...
3
by: Phil Endecott | last post by:
Dear All, I'm trying to read the content of the clipboard in a cross-browser way. Google will find various scripts such as this one: ...
3
by: tullyrob | last post by:
If you run the following simple line of code in Mozilla the webpage loads fine. However, a default page is displayed when opened in IE. --- <html> <iframe name=stbbox...
1
by: damezumari | last post by:
I have an iframe in my code: <iframe src ="../intro.php?text='.urlencode($line).'" name="scroll" marginwidth="10" marginheight="10"width="500" height="200" frameborder="1"></iframe> where...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.