explain me javascript:void(0)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    explain me javascript:void(0)

    plz explain in details about javascript:void (0)

    any help is most welcome ...............
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by dmjpro
    plz explain in details about javascript:void (0)

    any help is most welcome ...............
    Use it when you dont't want to load a page when a link is clicked.

    The important thing to know is that if you use a Javascript statement as the URL that returns a value the browser will attempt to load a page.

    To prevent this you need to use the void function on such statement, which will always return null and never load a new page.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      thanx for ur reply .....

      can't u give me link ......

      thanx in advance

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Here's a link.

        However, it is sometimes (maybe all the time) better not to use it not only because it causes problems in IE, but also because it is not the recommended way and not best practice. If you want to avoid following the link, set the href to a local fall-back page and in the onclick, have "return false" at the end. You will achieve the same effect with the addition that it won't break if the user has javascript turned off. See this link.

        Comment

        Working...