bulldog8@lycos.com a écrit :
Quote:
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 ...
Quote:
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>
Quote:
<div id="graphic">
<script>ShowPic("company_name.gif", 1255, 324)</script>
</div>
[...]
Quote:
<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">
Quote:
but to no success. I do not think I can depend on the Java console to
help debug,
JavaScript console
Quote:
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)
Quote:
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