here But what does void(0) here mean?"/> here But what does void(0) here mean?">
Home > Article > Web Front-end > js javascript:void(0) real meaning
I think code like this is common among those who have used ajax:
here
But what exactly is void(0) here? What’s the meaning?
void is an operator in Javascript, which specifies that an expression is to be evaluated but does not return a value.
void 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 are a good practice to write. (Implementation version Navigator 3.0 )
You can use the void operator to specify a hyperlink. The expression will be evaluated but nothing will be loaded into the current document.
The code below creates a hyperlink and nothing happens to the user later. When the user links, void(0) evaluates to 0, but has no effect on the Javascript.
Nothing will happen here
The following code creates a hyperlink that will submit the form when the user clicks.
Submit form here
The difference between a href=# and a href=javascript:void(0) There are several ways to link
# contains a location information
The default anchor is #top, which is the top of the webpage
And javascript:void(0) only represents a dead link
This is why sometimes the page is very The long browsing link is obviously # and it
jumps to the top of the page
but javascript:void(0) is not the case
so when calling the script it is best to use void(0)
or
< ;div onclick> etc.
Several ways to link
1.window.open(''url'')
2. Use a custom function
.target = "_ Blank";
obj.href = "web/substation/substation.aspx? stationno ="+tag;
obj.click (); = " javascript:void(0)" onclick="openWin(3,this)">Zhuzhou
window.location.href=""