The difference between a href=# and a href=javascript:void(0) Several ways to open a new window link

The difference between a href=# and a href=javascript:void(0) Several ways to open a new window link

 

# Contains a location information

The default anchor is #top which is the top of the page

And javascript:void(0) just means a dead link

This is why sometimes the page is very long and the browsing link is obviously #but

jumped to the top of the page

Not so with javascript:void(0)

So it is best to use void(0) when calling the script

or <input onclick>

<div onclick>, etc.

Several ways to open a new window link

1.window.open('url')

2. Use a custom function

        <script>
        function openWin(tag,obj)
        {
            obj.target="_blank";
            obj.href = "Web/Substation/Substation.aspx?stationno="+tag;
            obj.click();
        }
        </script>

<a  href="javascript:void(0)" οnclick="openWin(3,this)">株洲</a>

Guess you like

Origin blog.csdn.net/sinat_30603081/article/details/130777726