Personally measured the following:
<a href= "javascript:void (0)" onclick= "on" > Link </a>: Execute on function First, page does not move
<a href= "#" onclick= "on" > Link </a>: Perform the on function first, go back to the top
<a href= "https://www.baidu.com" onclick= "on" > Link </a>: Execute on function First, then skip to Baidu homepage
Supplement <a href= "Javascript:fun ();" : Tune into the fun function
The following is the user summary:
javascript: is a pseudo-protocol that indicates that the contents of a URL are executed through JavaScript.
void (0) means no action is made, which prevents the link from jumping to another page.
This is often done to preserve the style of the link, but does not allow the link to do the actual operation, the specific action to the link onclick event processing
void (0) is a piece of JavaScript code, the return value is undefined,href= ' javascript:undefined ' When you point the link,
But not doing anything. The reason for this is to add the onclick event with JS to this <a>,
To do as a link. The advantage is that the mouse is hand-shaped when linked, and the user does not know what the link is doing.
<a href= "#" onclick= "Window.close ()" > Close </a>
The href= "#" refers to the link to the current page, in fact, is meaningless, the page will not be refreshed, the key is the following onclick, when clicked "Close", will execute the Window.close () code.
You might say why not just write <a onclick= "Window.close ()" > Close </a>
If you write this, closing the two words will not work as a hyperlink, and the effect will look worse. You can try it yourself.
I'll tell you in detail. Javascript:void (0) represents some links with no return value, usually for example:
<a href= "javascript:void (0)" onclick= "on" > Links </a>
There is no return value for the OnClick event, and the page does not change the product. If you don't add this, you'll go back to the top.
Supplement <a href= "Javascript:fun ();"
So click to execute the fun () function
href= "javascript:void (0)"