By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,481 Members | 1,713 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,481 IT Pros & Developers. It's quick & easy.

Compatability Between IE and Netscape (Event Property?)

P: n/a
What is the equivalent of

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

in Netscape?
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.