#1
  1. No Profile Picture
    Breaker of programs, destroyer of worlds!
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    20
    Rep Power
    0

    A href --> Javascript Function


    I know this can be done, but I can't remember how:

    I have a link that I need to activate a function when clicked:

    <a href="#" onclick="nouse()">Link</a>

    This doesn't work and reloads the same page. I have used a link that was SOMETHING like this:

    <A href="javascript:nouse()">Link</a>

    The above doesn't work, but I remember it was SOMETHING like that. Any help would be appreciated!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    USA
    Posts
    226
    Rep Power
    15
    Your second interation is correct.

    <a href="javascript:whatever_function()">link</a>

    If the function is located on the page, it will work.
  4. #3
  5. No Profile Picture
    Breaker of programs, destroyer of worlds!
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    20
    Rep Power
    0
    Thanks for the reply, that's not working for me. here is my code:

    <head>
    <title>Absolute Impressions, Inc. Helping your business grow</title>
    <link href="ai.css" rel="styleSheet" type="text/css">
    <script language="javascript">
    <--
    function not_used() {
    alert("We are sorry, this domain is no longer in use.");
    }
    //-->
    </script>
    </head>

    And here is my link:

    <a href="javascript:not_used()">link</a>

    I'm getting an error on my page through IE5.5 now that says:
    "Line 1 Char 1 Object Expected"
    This is a bad error message because this is what is at line 1:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    Any help is appreciated!
  6. #4
  7. No Profile Picture
    Breaker of programs, destroyer of worlds!
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    20
    Rep Power
    0

    Unhappy Nevermind!


    The script started with <-- not <!--
    I changed it and everything works like a dream. I didn't think it would be that difficult! Thanks for the help!

    -Matt

IMN logo majestic logo threadwatch logo seochat tools logo