Results 1 to 3 of 3

Thread: javascript

  1. #1
    Join Date
    Dec 1969

    Default javascript

    Hi <BR><BR>Can anybody tell me how I can run a javascript function when I click on a hyperlink? like I have "click here" on my webpage and when somebody click on that, it has to run the javascript function. How can I do that. Thanks..Pam

  2. #2
    Join Date
    Dec 1969

    Default RE: javascript

    You need to add an onClick event to the hyperlink:<BR><BR>&#060;a href="#" onClick="NameOfFunctionHere()"&#062;click here&#060;/a&#062;<BR><BR>(I think that&#039;ll work, I&#039;ve not tested it though :)<BR><BR>Chris

  3. #3
    Joel N Guest

    Default RE: javascript

    You probably want to call it this way:<BR><BR>&#060;a href="#" onClick = "return NameOfFunctionHere();"&#062;click here&#060;/a&#062;<BR><BR>From "NameOfFunctionHere()" you&#039;ll probably want to decide whether or not to follow the link, so return "true" to follow it and return "false" to not follow it. With the sample code Chris shows you&#039;ll have to set the href property of the link in the function since it&#039;s set to "#" when the page loads.<BR><BR>HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts