Difference between # And void in javascript

Source: Internet
Author: User

First, let's create an experiment.
Open a blank page in any browser and enter the following code in the address input column: Copy codeThe Code is as follows: javascript: void (3 );

What will happen?
The answer is nothing happens.
Then, open a blank browser page and enter the following code in the address bar:Copy codeThe Code is as follows: javascript: function test () {return "hello" ;}; test ();

What will happen in this way? Will nothing happen?
Obviously not. We get a new page, and the page content is the value returned by the JS Code (that is, hello );
Why?
Because when the browser parses JS, if there is a return value, a new page will be generated, and if there is no, nothing will be done.
This is why the two examples above have such a difference.
Okay, let's get started.
Let's take a look at the two very similar codes.Copy codeThe Code is as follows: <a href = "#"> hyperlink </a>

Copy codeThe Code is as follows: <a href = "javascript: void (3);"> hyperlink2 </a>

Then, we put the two broken codes on the same page and click them one by one.
It seems that nothing has happened. Is it true that they are equivalent?
Let's look at a piece of code.Copy codeThe Code is as follows: <! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>
<BODY>
Here is the page header.
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
[Br]
[Br]
[Br]
[Br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br] [br]] [br] [br] [br] [br] [br] [br] [br]
<A href = "#"> href = # hyperlink </a>
<A href = "javascript: void (3 + 1); alert ('hello');"> href = javascript: void (3 + 1 ); </a>
</BODY>
</HTML>

In this way, we can click two links to see if the effect is different.
If href is #, the page is displayed.
The original '#' represents # top,
The top attribute returns the top-level parent window.
This attribute returns the read-only reference of a top-level window. If the window itself is a top-level window, the top attribute stores references to the window itself. If the window is a framework, the top attribute references the top-level window containing the framework.
The void function returns NULL, that is, to let the browser do nothing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.