#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Adelaide
    Posts
    72
    Rep Power
    13

    difference between javascript:null(0) and #


    Hi,
    I know that when you use <a href="javascript:null(0)" onClick="open_win()">, it will not refresh the original page but just open the new window.

    But when you use "<a href="#" onClick="open_win()">", does this refresh the original page and then open a new window??

    Also does the first option work in some versions of IE (example 5.5 but not in 5.0) only??
    Could you tell me which option would work in any version of IE??

    Thanks for any replies.

    Regards,

    Yoshi
    thats why i'm easy.....easy like sunday morning!
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Me again.

    Here's the lowdown:

    1)User clicks on link.
    2)onclick handler executes.
    3)Unless click event is then explicitly cancelled - by a) returning false, b) cancelling the bubbling of the event (IE/NS6), c) setting the event's returnValue - a property - to false - or d) some other new ways with the latest event model,
    4)href is loaded.

    If href="#", the hash mark indicates an anchor; since no anchor name is specified, it takes you to the top of the current page (with a reload). Not sure about the IE version question, but

    <a href="#" onClick="open_win();return false;">

    should work anywhere JavaScript/JScript is enabled.

    adios
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Adelaide
    Posts
    72
    Rep Power
    13

    Thanks


    Adios,
    Thanks for your reply. Most of it made sense. I was under the impression that javascript:null(0) worked in any browser version too.

    Anyway no worries, problem solved and learned something too.

    Later,

    Yoshi
    thats why i'm easy.....easy like sunday morning!
  6. #4
  7. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    javascript&#58;void(0) might; javascript&#58;; (a MM fave) is sometimes used too...just return false; Yoshi, kills events like rat poison...

IMN logo majestic logo threadwatch logo seochat tools logo