What are the differences between href=# and href=javascript:void(0)? The following is my summary of the difference between href=javascript:void(0) and href=#.
#"Contains a location information
The default anchor point is #top, which is the top of the web page
And javascript:void(0) only represents a Dead link
This is why sometimes the page is very long and the browsing link is obviously #but jumps to the top of the page
But javascript:void(0) is not like this
So When calling the script, it is best to use void(0)
or onclick>
wait
to open a new Several ways to link windows
1.window.open('url')
2.Use 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)" onclick="openWin(3,this)">LINK_TEST</a> window.location.href=""
--- -------------------------------------------------- --------------------------
If it is a #, it will jump to the top. Several personal favorites Solution:
1:<a href="####"></a> 2:<a href="javascript:void(0)"></a> 3:<a href="javascript:void( null )"></a> 4:<a href="#" onclick=" return false"></a> 5:<span style="cursor:hand"></span>(好像在FF中不能显示)
------------------------------------- ------------------------------------------
Use with caution JavaScript:void(0)
void in JavaScript is a operator, which specifies to evaluate an expressionbut does not return a value
void. The operator usage format is as follows:
1. javascript:void (expression) 2. javascript:void expression
expression is a JavaScript standard expression to be evaluated. The parentheses outside the expression are optional, but it is a good habit to write them. The void operator specifies a hyperlink. The expression is evaluated but nothing is loaded into the current document. The code above creates a hyperlink and nothing happens when the user clicks the link. (0) is calculated as 0, but has no effect on JavaScript
<a href="javascript:void(0)">单击此处什么也不会发生</a>
That is to say, if you want to perform some processing without refreshing the page as a whole, you can use void(0). , but when you need to refresh the page, you need to be careful.
【Related Recommendations】
1. Special Recommendation:"php Programmer Toolbox" V0.1 version Download
2. Solution to the invalid method of javascript:void(0) under ie6
3. Javascript Definition and detailed explanation of operator void(0)
4. Use javascript:void(0) with caution, why is it not good to write like this
The above is the detailed content of Summarize the differences between href=javascript:void(0) and href=#. For more information, please follow other related articles on the PHP Chinese website!