Mozilla - Changing iFrame source

B

bulldog8

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").innerHTML = '<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").innerHTML" 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
 
A

ASM

(e-mail address removed) 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").innerHTML = '<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 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").innerHTML" 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").innerHTML
could do what you expect

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

parent.ShowPic(blah);
 
B

bulldog8

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top