Home  >  Article  >  Web Front-end  >  What does javascript:void(0) mean and an example introduction_javascript skills

What does javascript:void(0) mean and an example introduction_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:14:391829browse

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 to be calculated expression. 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 following code creates a hyperlink that will cause nothing to happen to the user later. When the user links, void(0) evaluates to 0, but nothing happens on Javascript:

Nothing happens here< ;/A>

The following code creates a hyperlink and the user will submit the form when clicking:

Submit form here

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 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 #
Jumps to the top of the page

, but javascript:void(0) is not like this

, so it is best to use
void(0)
or
< when calling the script input onclick>

etc.

Several ways to link

1.window.open(''url'')
2. Use a custom function

Copy code The code is as follows:

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

window .location.href=""
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn