Image Load in IE vs. Mozilla

F

Frank Carr

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>
 
L

Lasse Reichstein Nielsen

Frank Carr said:
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
 
F

Frank Carr

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.
 
L

Lasse Reichstein Nielsen

Julian Harse said:
'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
 
S

Stephen Poley

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:..." 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.
 
F

Frank Carr

"<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.
 
S

Stephen Poley

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?
 
F

Frank Carr

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.
 

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,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top