SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to put empty link

    Hello guys,

    I wonder how can I put empty link into the "a href" element? I use this link to call JS function:

    <a href="#" onClick="function();">
    But "#" is not empty link, when I click on it, browser moves page.

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you returning false from your javascript function? That should make the link inactive.

  3. #3
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nickohrn View Post
    Are you returning false from your javascript function? That should make the link inactive.
    Thanks for advice. I've added return false; to the function, but now function doesn't work.

  4. #4
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by al9 View Post
    Thanks for advice. I've added return false; to the function, but now function doesn't work.
    Then you must have put it in the wrong place.

    If the function always returns false, use:
    Code:
    <a href="#" onclick="return function();">
    Otherwise:
    Code:
    <a href="#" onclick="function();return false">
    Tab-indentation is a crime against humanity.

  5. #5
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had error in JS code.

    This method works. Thanks for help guys.

  6. #6
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do u need an empty link at all??? can u not just put the onclick function in the containind span or div or watever it is?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)


Bookmarks

Posting Permissions

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