亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript:void(0) meaning

We often use code like javascript:void(0), so what does javascript:void(0) mean in JavaScript?

The most critical thing in javascript:void(0) is the void keyword. void is a very important keyword in JavaScript. This operator specifies to calculate an expression but does not return a value.

The syntax format is as follows:

<head>
<script type="text/javascript">
<!--
void func()
javascript:void func()
或者
void(func())
javascript:void(func())
//-->
</script>
</head>


<!DOCTYPE html> 
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
</head> 
<body>
    <a href="javascript:void(0)">點(diǎn)擊此處什么也不會發(fā)生</a>
</body>
</html>


When the user links, void(0) evaluates to 0, but Nothing works on Javascript.

In the following example, a warning message is displayed after the user clicks the link:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文網(wǎng)(php.cn)</title>
<script type="text/javascript">
</script>
</head>
<body>
<a href="javascript:void(alert('有誤'))">點(diǎn)擊</a>
</body>
</html>

In the following example, parameter a will return undefined:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<script type="text/javascript">
function getValue(){
   var a,b,c;
   a = void ( b = 5, c = 7 );
   document.write('a = ' + a + ' b = ' + b +' c = ' + c );
}
</script>
</head>
<body>
<form>
<input type="button" value="單擊" onclick="getValue();" />
</form>
</body>
</html>


The difference between href="#" and href="javascript:void(0)"

# contains a location information, the default anchor is #top, which is the web page the upper end.

And javascript:void(0) only represents a dead link.

When the page is very long, # will be used to locate the specific location of the page. The format is: # + id.

If you want to define a dead link, please use javascript:void(0).

<a href="javascript:void(0);">點(diǎn)擊沒反應(yīng)</a> 
<a href="#pos">單擊跳轉(zhuǎn)</a> 
<br> 
... 
<br> 
<p id="pos">尾部定位點(diǎn)</p>


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> function openWin(tag,obj) { obj.target="_blank"; obj.href = "Web/Substation/Substation.aspx?stationno="+tag; obj.click(); } </script> </head> <body> <p>點(diǎn)擊開始跳轉(zhuǎn)</p> <a href="javascript:void(0)" onclick="openWin(3,this)">LINK_TEST</a> </body> </html>
submitReset Code