Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - using "this" in javascript/XHTML >Thread Next - Re: using "this" in javascript/XHTML Re: using "this" in javascript/XHTMLTo: NULL Date: 11/1/2004 6:23:00 PM
Mike Kamermans wrote:
> I'm trying to determine where inside an XHTML's DOM a javascript function
> is triggered, but when I use the construction of calling a function with
> "this" as parameter and then checking the event target inside the
> javascript function, I get very very little love from javascript in an
> XHTML setting.... I have put up the file that demonstrates my problem at:
>
> http://www.nihongoresources.com/downloads/test/test.xml
>
> (the jscript bit is http://www.nihongoresources.com/downloads/test/test.js)
>
> If anyone knows what I'm doing wrong here, I'd appreciate any help =/
First of all
window.event
is something IE supports but not something the W3C DOM wants so if you
want to script Mozilla make sure you pass the event object as a
parameter e.g.
<a onclick="change(event);"
with
function change (evt) {
// access for instance evt.target here
alert(evt.target);
}
As for the this object, you have
<a onclick="change(this)"
and traditionally the toString() value of an <a> element is its href
attribute, as you don't have a href attribute the alert shows nothing,
try instead
<a onclick="change(this);">
with
function change (obj) {
alert(obj.tagName)
and you will see that the object passed in is indeed an <a> element.
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
