469,306 Members | 1,987 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Compatability Between IE and Netscape (Event Property?)

What is the equivalent of

if (window.event.srcElement.id == "txt1ST_INIT_NM")

in Netscape?
Jul 20 '05 #1
2 1173
DU
Ron D wrote:
What is the equivalent of

if (window.event.srcElement.id == "txt1ST_INIT_NM")

in Netscape?


if(evt.target.id == "txt1ST_INIT_NM")
in NS 6+, Mozilla-based browsers, in Opera 7.x and in all other W3C DOM
2 Events compliant browsers.

We would also need to see your code, script function to implement an
event listener. Also, depending on your code (capture mode or bubbling
up) and how complex it is, you might be forced to use
evt.currentTarget.id instead.
It's impossible to say more without being able to actually examine your
whole code.

DU
Jul 20 '05 #2
du*****@rrb.gov (Ron D) writes:
What is the equivalent of

if (window.event.srcElement.id == "txt1ST_INIT_NM")

in Netscape?


In Netscape 6+ (and other W3C DOM 3 Events compliant browsers, as well
as in Nescape 4) the event object is an argument to the event handler
function. In IE, it is a global variabled called "event". So, there is
no direct substitute for the above, because you have to add an argument
to the handler function.

I usually start my handlers with :

function (evt) {
evt = evt || window.event; // IE sucks!

Further, the "srcElement" is Microsoft's invention, where the W3C DOM
calls it "target". So I usually follow up with:

var tgt = evt.target || evt.srcElement; // IE sucks!

From here, you can just write:

if (tgt.id == "txt1ST_INIT_NM") ...

Good luck.

/L 'yes, I write the comments every time too'
--
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 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by adrien | last post: by
2 posts views Thread by Phil | last post: by
2 posts views Thread by Kevin Ly | last post: by
2 posts views Thread by Lynn | last post: by
26 posts views Thread by Roger Desparois | last post: by
4 posts views Thread by WStoreyII | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.