Re: srcElement in IE = what in Netscape?

Giganews Newsgroups
Subject: Re: srcElement in IE = what in Netscape?
Posted by:  Lasse Reichstein Nielsen (l…@hotpop.com)
Date: 28 Jul 2003

"Dan" <hgfgh…@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  -  l…@hotpop.com
Art D'HTML: <URLhttp://www.infimum.dk/HTML/randomArtSplit.html>
  'Faith without judgement merely degrades the spirit divine.'

Replies

In response to

srcElement in IE = what in Netscape? posted by Dan on Mon, 28 Jul 2003