In defense of javascript: void (0);

    The other day I decided to watch the news via Google . I right-click on the link “other news” and in the context menu there is no item to open in a new window. I decided to look at the source code and see javascript: void (0);
    For me, this was news, because everything that I read before that was clearly against such a decision.


    I mean the situation when the link runs some js code and is not used for its intended purpose, then what markup is better to use?
    ...
    or
    ...

    Void is better href = "#" since the behavior of href = "#" when opening in a new window is unexpected for users: the user clicks on 15 links with the right mouse button and opens each in a new tab. As a result, he has 16 tabs with the same document.

    So if suddenly the standard “javascript:” is canceled there are no collisions, use onclick = “return false;” with it. Spy on Google News:

    ...

    Also popular now: