S
stevewy
Having Googled the internet generally, and searched this group, I
still cannot find any definitive answer to the question about how to
get an equivalent of "srcElement" and "event" in Firefox.
I've known for some time that I shouldn't use just "srcElement" to
reference which element has been clicked on, because it is only
supported by Internet Explorer, not Firefox etc. I thought I was
alright by using a combination of "srcElement" and "Target", so that I
thought the following would work (in IE and Firefox) in a function:
var obj=event.srcElement || event.target;
if (obj.type=="checkbox"){... etc
However, this validation doesn't work properly in Firefox. Firefox's
Error Console informs me that "event" is not an object, and it turns
out that Firefox does not recognise "event.target" after all.
I have looked on the internet about this but can find no "definitive"
solution. Plenty of sites saying that event is not supported in
Firefox.
Can anyone advise on a general bit of code that would work as a
substitute for "event.srcElement" and be compatible with Firefox? Is
it something simple like document.event.target or window.event.target
(except without the word "event", apparently...)?
I do have a little function to disable the Return key, that stops
people prematurely submitting the form just by pressing Enter (below),
and that achieves cross-browser compatibility - but I am uncertain why
"evt" appears in the function name as a parameter, when the
"document.onkeypress" doesn't actually pass up any parameters...
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ?
evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type!="textarea")) {return
false;}
}
document.onkeypress = checkCR;
Hope you can help.
Steve Wylie
src.Confused
still cannot find any definitive answer to the question about how to
get an equivalent of "srcElement" and "event" in Firefox.
I've known for some time that I shouldn't use just "srcElement" to
reference which element has been clicked on, because it is only
supported by Internet Explorer, not Firefox etc. I thought I was
alright by using a combination of "srcElement" and "Target", so that I
thought the following would work (in IE and Firefox) in a function:
var obj=event.srcElement || event.target;
if (obj.type=="checkbox"){... etc
However, this validation doesn't work properly in Firefox. Firefox's
Error Console informs me that "event" is not an object, and it turns
out that Firefox does not recognise "event.target" after all.
I have looked on the internet about this but can find no "definitive"
solution. Plenty of sites saying that event is not supported in
Firefox.
Can anyone advise on a general bit of code that would work as a
substitute for "event.srcElement" and be compatible with Firefox? Is
it something simple like document.event.target or window.event.target
(except without the word "event", apparently...)?
I do have a little function to disable the Return key, that stops
people prematurely submitting the form just by pressing Enter (below),
and that achieves cross-browser compatibility - but I am uncertain why
"evt" appears in the function name as a parameter, when the
"document.onkeypress" doesn't actually pass up any parameters...
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ?
evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type!="textarea")) {return
false;}
}
document.onkeypress = checkCR;
Hope you can help.
Steve Wylie
src.Confused