INPUT type=image

  • Thread starter Thread starter dwa
  • Start date Start date
D

dwa

This is a bit off-topic, but...

Is it possible to write client side script that can address INPUT controls
with a type of "image" which will work under Netscape/Mozilla?

<INPUT type="image" ...>

Controls of this type are excluded from the forms[].elements collection and
'document.all[]' isn't supported my Mozilla browsers?

Any way to do this?

-- dwa
 
Hi Dwa,



Thanks for posting in the community!
From your description, you'd like to address and do some operations on a
<input type=image..> control in a web page via client side javascript.
Also, you found that the "document.all" member isn't supported by Mozilla
explorer, yes?
If there is anything I misunderstood, please feel free to let me know.

Based on my research, this problem does due to the different browsers have
different supports on the javascript apis, the "document.all" is not
supported in Mozilla, in Mozilla, we need to use the
"document.getElementById()" to get an page element by its id, and I've
tested using the below code in Mozilla 1.6, it worked well.
----------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript" >
function SetImgSrc(oid)
{
document.getElementById(oid).src =
'http://msdn.microsoft.com/library/mnp/2/gif/banner/bnr_msdn_LTR.gif';
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td>
<IMG id="imgImg" alt="MSDN"
src="http://msdn.microsoft.com/nodehomes/graphics/msdnevents.gif">
<input id="imgInput" type="image"
src="http://msdn.microsoft.com/nodehomes/graphics/msdnevents.gif">
</td>
</tr>
<tr>
<td>
<INPUT id="btnImg" type="button" value="Change Img's src"
onclick="SetImgSrc('imgImg')" >
<INPUT id="btnInput" type="button" value="Change input's src"
onclick="SetImgSrc('imgInput')" >
</td>
</tr>
</table>
</form>
</body>
</HTML>
---------------------------------------------
Please also try it out on your side to see whether it works. In addition,
here is a tech aritcle which has discussed on
how to set src attribute via clientside javascript under different browsers
such as IE, NETSCAPE, MOZILLA,:

#Extending setSrc() to Mozilla Browsers
http://www.webreference.com/js/tips/010126.html

I believe it also helpful to you.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top