By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,808 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

Image Load in IE vs. Mozilla

P: n/a
I'm trying to load a matching image when a link is clicked. The following
test page works OK (the pictures load when their link is clicked) in IE6 but
it does not work in Mozilla 1.5.

----------------------------------------------------------------------------
------------------
<html>
<head>
<title>Test Page</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function ShowPic1()
{
document.getElementById('imgShow').width = 84;
document.getElementById('imgShow').height = 118;
document.getElementById('imgShow').src = 'images/test_1.gif';
}

function ShowPic2()
{
document.getElementById('imgShow').width = 103;
document.getElementById('imgShow').height = 117;
document.getElementById('imgShow').src='images/test_2.gif';
}
</SCRIPT>
<body>
<a href="javascript:ShowPic1()">Picture #1</a><br>
<a href="javascript:ShowPic2()">Picture #2</a><br>
<br><br>
<img name="imgShow" src="" width="0" height="0"></img>
</body>
</html>
----------------------------------------------------------------------------
------------------

TIA for any assistance...

--
Frank Carr
jf****@msn.com
http://www15.brinkster.com/vbnotebook
Jul 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"Frank Carr" <jf****@msn.com> writes:
I'm trying to load a matching image when a link is clicked. The following
test page works OK (the pictures load when their link is clicked) in IE6 but
it does not work in Mozilla 1.5.
With good reason. document.getElementById('imgShow').width = 84;
You use getElementById (the keyword is "Id"), but
<img name="imgShow" src="" width="0" height="0"></img>


You don't give the img element an id, just a name. Change "name=" to
"id=", and it should work.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:oe**********@hotpop.com...
You don't give the img element an id, just a name. Change "name=" to
"id=", and it should work.


Thanks...I should have caught that one. Interesting how IE seems to treat
'name' and 'id' the same.
--
Frank Carr
jf****@msn.com
http://www15.brinkster.com/vbnotebook
Jul 20 '05 #3

P: n/a
Frank Carr wrote:
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:oe**********@hotpop.com...
You don't give the img element an id, just a name. Change "name=" to
"id=", and it should work.


Thanks...I should have caught that one. Interesting how IE seems to
treat 'name' and 'id' the same.


'name' is a legacy property which has been marked for depreciation by the
w3c
Jul 20 '05 #4

P: n/a
"Julian Harse" <ju****@cbtdesign.com> writes:
'name' is a legacy property which has been marked for depreciation by the
w3c


Not in all cases. Only in the cases where it is used to give the
anchor name of the element. Exceptions are form controls (where it
gives the control name), param and meta.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

P: n/a
On Sun, 30 Nov 2003 19:15:10 GMT, "Frank Carr" <jf****@msn.com> wrote:
I'm trying to load a matching image when a link is clicked. The following
test page works OK (the pictures load when their link is clicked) in IE6 but
it does not work in Mozilla 1.5.

------------------
<a href="javascript:ShowPic1()">Picture #1</a><br> ------------------

TIA for any assistance...


"<a href="javascript:..." is not a good move, as it means that anyone
without Javascript can't see the picture at all. Better to have
<a href="images/test_1.gif" and use onclick to place it where you want
on the page.

--
Stephen Poley
Jul 20 '05 #6

P: n/a
"Stephen Poley" <sb*****@xs4all.nl> wrote in message
news:4s********************************@4ax.com...
"<a href="javascript:..." is not a good move, as it means that anyone
without Javascript can't see the picture at all. Better to have
<a href="images/test_1.gif" and use onclick to place it where you want
on the page.


The actual pages I'm putting together will probably need to require
Javascript. In the 'non-test' pages a variable number of image files are
selected and uploaded by a separate backend process on a regular basis and a
list of files and their description is put into an array in a separate JS
file. Without having Javascript, the link itself wouldn't be there in the
first place since it's generated in the onload() processing.

If you have any alternative suggestions on how to do this (aside from
running things server side in ASP, JSP, or PHP which I can't do in this
case) I'd like to hear about them.

--
Frank Carr
jf****@msn.com
http://www15.brinkster.com/vbnotebook
Jul 20 '05 #7

P: n/a
On Tue, 02 Dec 2003 13:40:22 GMT, "Frank Carr" <jf****@msn.com> wrote:
"Stephen Poley" <sb*****@xs4all.nl> wrote in message
news:4s********************************@4ax.com.. .
"<a href="javascript:..." is not a good move, as it means that anyone
without Javascript can't see the picture at all. Better to have
<a href="images/test_1.gif" and use onclick to place it where you want
on the page.


The actual pages I'm putting together will probably need to require
Javascript. In the 'non-test' pages a variable number of image files are
selected and uploaded by a separate backend process on a regular basis and a
list of files and their description is put into an array in a separate JS
file. Without having Javascript, the link itself wouldn't be there in the
first place since it's generated in the onload() processing.

If you have any alternative suggestions on how to do this (aside from
running things server side in ASP, JSP, or PHP which I can't do in this
case) I'd like to hear about them.


Well, I'm not 100% sure what your situation is. But if you've got things
being changed dynamically by a back-end process, it does sound as if PHP
/ JSP / ASP would be the way to go. Or Perl. If you are running such
processes, why is it not possible to use one of those four?

--
Stephen Poley
Jul 20 '05 #8

P: n/a
"Stephen Poley" <sb*****@xs4all.nl> wrote in message
news:i0********************************@4ax.com...
Well, I'm not 100% sure what your situation is. But if you've got things
being changed dynamically by a back-end process, it does sound as if PHP
/ JSP / ASP would be the way to go. Or Perl. If you are running such
processes, why is it not possible to use one of those four?


As usual, it goes back to the server that I have to run this on (ie a client
with cheap rented web space). It would be my preference to run it under ASP
or ASP.NET since that's what I have the most experience in but I don't get
that choice this time around.

--
Frank Carr
jf****@msn.com
http://www15.brinkster.com/vbnotebook
Jul 20 '05 #9

P: n/a
Lasse Reichstein Nielsen wrote:
"Julian Harse" <ju****@cbtdesign.com> writes:
'name' is a legacy property which has been marked for depreciation
by the w3c


Not in all cases. Only in the cases where it is used to give the
anchor name of the element. Exceptions are form controls (where it
gives the control name), param and meta.


good point, didn't think about those ; )
Jul 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.