faqts : Computers : Programming : Languages : JavaScript : Links

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

24 of 28 people (86%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do I pass links to a function?

Apr 22nd, 2000 03:05
Martin Honnen,


Write your function to receive one parameter, the link object
  function clickHandler (link) {
    alert(link.text ? link.text : link.innerText);
    return false;
  }
which you then call as 
  <A HREF="whatever.html"
     ONCLICK="return clickHandler(this)"
  >
Depending on what your function returns (false to cancel link, true to 
execute it), the link will be executed after the function was called.