JavaScript: This particular protocol type declares that the subject of the URL is arbitrary JavaScript code, which is run by the JavaScript interpreter.
For example, the following dead link:
<href= "javascript:void (0)">No response link</A >
The way to add JavaScript code to the client is to place it in the URL of the pseudo-protocol description symbol javascript: Post. This particular protocol type declares that the subject of the URL is arbitrary JavaScript code, which is run by the JavaScript interpreter. If the JavaScript code in Javascript:url contains multiple statements, you must separate the statements with semicolons. Such URLs are as follows:
Javascript:var now =new Date (); " < H1 > This time:</H1>"+now;
When the browser loads such a URL, it executes the JavaScript code contained in the URL and displays the string value of the last JavaScript statement as the content of the new document. This string can contain HTML tags and be formatted exactly like other document types loaded into the browser. JavaScript URLs can also perform actions only, but do not reverse the JavaScript statements. For example:
Javascript:alert ("Hello World")
When this URL is loaded, the browser executes only the JavaScript code in it, but because there is no value to display as a new document, it does not change the currently displayed document.
Usually we want to use Javascript:url to execute some JavaScript code that does not change the currently displayed document. To do this, you must ensure that the last statement in the URL does not have a return value. One way is to specify the return value as undefined with the void operator, just use the statement void 0 at the end of Javascript:url. For example: The following URL opens a new, empty browser window without changing the current window's class capacity:
Javascript:window.open ("About:blank"); void 0;
If the URL does not have a URL run, the return value of the window.open () method will be converted to a string and displayed, and the current window will be overwritten by the following document.
I'll check the original.
The use of Pseudo-protocol (javascript:) in "JavaScript" javascript