[Javascript] Capturing which link/button is clicked
Esther_Strom at hmco.com
Esther_Strom at hmco.com
Tue Nov 27 08:48:13 CST 2001
Thanks, Peter. That looks like what I need. I was hoping there might be an
easier way, but I guess not.
Esther
"Peter-Paul Koch"
<gassinaumasis at ho To: javascript at LaTech.edu
tmail.com> cc:
Sent by: Subject: Re: [Javascript] Capturing which link/button is clicked
javascript-admin@
LaTech.edu
11/27/01 02:43 AM
Please respond to
javascript
>For reasons I don't pretend to ignore, a colleague has set up a form so
>that no matter which link is clicked on, an onUnload script changes the
>location. For example:
>
><a href="goToThisPage.html">Go here</a>
>
>onUnload="window.location.href='goToThisPageInstead.html'"
>
>(The URL in onUnload isn't actually an HTML page, but a Domino agent that
>runs onUnload. Just using .html above for clarity.)
>
>Anyway, I now need to find a way to capture the URL on the link that was
>actually clicked. Compounding this problem is that not all clickable
things
>are links; some are buttons that run other agents, or javascript
functions.
You have to set onclick events on all this stuff and then read out the
hrefs. For instance, for all links
var a = document.getElementsByTagName('A');
for (var i=0;i<a.length;i++)
a[i].onclick = detect;
Now all links have a onClick event handler that sends the onclick to
function detect(e)
{
if (e) tg = e.target;
else tg = window.event.srcElement;
theHref = tg.[I've forgotten, link?, href?]
}
I've forgotten how to get the href out of tg, which is now a link like in
document.links[]
Now you have the href of the link clicked on. However, how are you going to
send it outside the page if the page unloads directly after this detect and
goes somewhere else?
I'm not sure what you're supposed to make happen.
ppk
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list