Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: using "this" in javascript/XHTML

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent