...

View Full Version : Sending data about "this"



Kevlar
07-23-2002, 08:19 PM
I need a link to execute a JS command (cmd()). How do I send the "this.href" of the "a" tag to the command and then execute according to that info?

neil.c
07-23-2002, 08:22 PM
you mean this kind of thing?



<script>
function blah(url){
alert(url) //or whatever
}
</script>

<a href="page.html" onclick="blah(this.href)">

Kevlar
07-23-2002, 08:25 PM
Originally posted by neil.c
you mean this kind of thing?



<script>
function blah(url){
alert(url) //or whatever
}
</script>

<a href="page.html" onclick="blah(this.href)">


But how do you define "this.href" as "url"?

neil.c
07-23-2002, 08:31 PM
Originally posted by Kevlar

But how do you define "this.href" as "url"?

the function blah() has a new variable name (url) in its brackets. this means that whenever you call blah(), whatever you put into the brackets gets put into the url variable. in this case, it is this.href, i.e. the href of the link.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum