Results 1 to 4 of 4

Thread: Running Javascript when Link is clicked

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    492

    Running Javascript when Link is clicked

    Ok i am fairly new to Javascript programming. What i need to do is make a HTML webpage. On this webpage i will be placing a few links. What i need is to find out how i can make it so when a link is clicked a few lines of Javascript execute. Currently for testing purposes i am running my javascript in the head header of my HTML page. What needs to be done in order to achieve my goal.

    Code is greatly appreciated.

    Thanks

  2. #2
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    you use the onmouseclick parameter in the link tag.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Code:
    <script language="javascript">
    function whoozie(){
    //code
    //code
    end function
    </script>
    
    later on in your page...
    
    <a href="#" onClick="javascript:whoozie();">Click here</a>

  4. #4
    Member
    Join Date
    Jan 2003
    Posts
    44
    Language has been deprecated in favor of type, and the language for the value of the intrinsic event should be defined in a meta declaration.
    Code:
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function foo() {
    }
    </script>
    
    <p><a href="going_here_if_no_js.html" onclick="foo(); return false">click me</a></p>

Posting Permissions

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



Click Here to Expand Forum to Full Width