Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Capturing which link/button is clicked
- From: javascript@xxxxxxxxxx (javascript@xxxxxxxxxx)
- Subject: [Javascript] Capturing which link/button is clicked
- Date: Tue, 27 Nov 2001 08:48:13 -0600
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@ho To: javascript@xxxxxxxxxx
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@xxxxxxxxxx
http://www.LaTech.edu/mailman/listinfo/javascript
- Prev by Date: [Javascript] problems with NN6-accessing the dynamic field names in Javascri
- Next by Date: [Javascript] problems with NN6-accessing the dynamic field names in Javascript with NN
- Previous by thread: [Javascript] Capturing which link/button is clicked
- Next by thread: [Javascript] Formulario
- Index(es):