#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    A href and prevet default syntax


    Hi, I am creating links that need to override the href="link.htm" and call the javascript if Javascript is enabled.

    for example, I have the following
    Code:
    <a href="link.html" javascript:updatewith(linkbody), prevent default, false>link txt </a>
    I know my yntax is all messed up, but can someone whow me the correct way? If javascript is turned off, the href should work.

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    I found what I needed


    I found this:
    Code:
    <a href="arealpage.html" onclick="doSomething(); return false;">click for fun</a>
    Which seems to work

    -

    Comments on this post

    • KorRedDevil agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    maybe I'm overlooking something but . . .


    The code I posted doesn't seem to work. I thought I had it working yesterday, but today it is calling the "<a href=" command instead of the "onclick" command.

    Here is an example of my code:
    Code:
    <a href="about.html" class="bodyLink"  onclick="updateWith(about); return false;">Profile</a>
    Does anyone see why the onclick doesn't execute? The updateWith() is a javascript command I customized. It works when I call it from Flash, but not from a document loaded in the main page inside a <div> tag.

    any help is appreciated
    thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    fixed it


    I needed single quotes in the onclick=updateWith('about.htm') call

IMN logo majestic logo threadwatch logo seochat tools logo