Thanks for replying...
I tried different ways about this and maybe you can help me understand some
differences:
1) this works ('ev' is used instead of 'event')
<IMG ID="myimg" SRC="bugs.gif" >
<script type="text/javascript">
var ev;
lap=document.getElementById("myimg")
function downtest(ev)
{
var strid = ev.target.id;
alert(strid)
}
lap.onmousedown=downtest // WHY NOT
lap.onmousedown=downtest(ev) ??
</script>
2) this works too ('event' used)
<IMG ID="myimg" SRC="bugs.gif" onMouseDown=downtest(event)>
<script type="text/javascript">
lap=document.getElementById("myimg")
function downtest(event)
{
var strid = event.target.id;
alert(strid)
}
</script>
3) this doesn't work: why can 'event' not be replaces by 'ev'? error= ev has
no properties
<IMG ID="myimg" SRC="bugs.gif" onMouseDown=downtest(ev)>
<script type="text/javascript">
var ev;
lap=document.getElementById("myimg")
function downtest(ev)
{
var strid = ev.target.id;
alert(strid)
thanks for your time
Dan
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:pt**********@hotpop.com...
"Dan" <hg*****@dfgd.rf> writes:
When i click down with the mouse, i want to be sure that the image
"myimg" is clicked before doing something. With IE i use 'srcElement' and it
works:
The official name is "target". Also, there is no "window.event" in
Mozilla/Netscape, that is a Microsoft invention as well.
<IMG ID="myimg" SRC="bugs.gif" onMouseDown="downtest()">
<script>
<script type="text/javascript">
The type attribute is mandatory.
function downtestIE()
Try:
function downtest(event) {
event = event || window.event; // IE doesn't pass event as argument.
var tgt = event.target || event.srcElement; // IE doesn't use .target
var strid = tgt.id;
if (strid=="myimg")
{ etc ...
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'