The return here contains some detailed knowledge:
For example: the difference between onClick='return add_onclick()' and onClick='add_onclick()'
JAVASCRIPT uses return when calling a function in an event to actually set the window.event.returnvalue.
This value determines whether the current operation continues.
When true is returned, the operation will continue.
When the return is false, the operation will be interrupted.
When executed directly (without return). window.event.returnvalue will not be set
so the operation will continue by default
Details are as follows:
For example:
When in Open
If the function add_onclick( ) Return true, then the page will open abc.htm
Otherwise, (return false), then the page will not jump to abc.htm, and will only execute the content in your add_onclick() function. (In the add_onclick function Except for controlling the page to go to abc.htm
)
AndOpen
No matter what value add_onclick() returns, it will be opened after add_onclick is executed. Page abc.htm
In addition:
onclick event is equivalent to onclick="return true/false"
Example:
Return is not required to call the js function, but the form cannot be submitted, so add a sentence in the js function
Example:
About return false and return true in javascript
return is the keyword for function return value in javascript. The result processed within a function can be returned using return, so that where the function is called Variables can be used to receive the returned results. Any type of variable data or expression within the return keyword can be returned, or even nothing can be returned, such as