faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 2 people (0%) answered Yes
Recently 0 of 2 people (0%) answered Yes

Entry

is there any way a page's "onUnload" function can ascertain the URL of the link that was clicked?

Apr 8th, 2008 18:44
ha mo, Dave Clark, vasanth kumar,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vasanth,
     You can try this:
function CheckLink(e)
{
    var url = null;
    if (e) {
        if(e.type == 'click'
        && e.target.tagName == 'A') {
            url = e.target.href;
        }
    }
    else {
        if(event.type == 'click'
        && event.srcElement.tagName == 'A') {
            url = event.srcElement.href;
        }
    }
    if (url) alert(url);
    return true;
}
window.onunload = CheckLink;
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com