I have tried Ajax.Code:
<A href = "javascript: dotest2 (); void (0);"> here </a>
But what does void (0) mean?
In JavaScript, void is an operator that specifies to calculate an expression but does not return a value.
The format of the void operator is as follows:
1. javascript: void (expression)
2. javascript: void expression
Expression is a standard JavaScript expression to be calculated. Parentheses outside the expression are optional, but it is a good habit to write. (Implement version navigator 3.0)
You can use the void operator to specify a hyperlink. The expression is calculated, but no content is loaded in the current document.
The following code creates a hyperlink. Nothing happens after you click it. When a user clicks a link, void (0) is calculated as 0, but it has no effect on JavaScript.
<A href = "javascript: void (0)"> click here. </a>
The following code creates a hyperlink. When you click it, the form is submitted.
<A href = "javascript: void (document. Form. Submit ()"> click here to submit a form </a>
Under what circumstances will void (0) be used more often, without refreshing the new version? Of course it is Ajax. If you look at Ajax web pages, you will usually see a lot of void (0 ), so before using void (0), You 'd better first think about whether the page needs to be refreshed as a whole.
----------------------------------------------------------------------------
When using JavaScript, we usually use the following method: <a href = "#" onclick = "javascript: Method"> submit </a>, use a pseudo link to call the JavaScript method. This method has a problem: although the page is not redirected when you click the link, the scroll bar will roll up. The solution is to return to false.
As follows:
<A href = "#" onclick = "javascript: method; return false;"> submit </a>
<A href = "javascript: void (0)" onclick = "javascript: method; return false;"> submit </a>
Another method is # This
A href = "# This" onclick = "javascript: Method"
----------------------------------------------------------------------------
# Contains a location information
The default anchor is # top, that is, the top of the web page.
Javascript: void (0) only indicates a dead link.
This is why sometimes a long page browsing link is clearly # But the page jumps to the top
This is not the case with javascript: void (0 ).
Therefore, it is best to use void (0) or <input onclick> <Div onclick> when calling a script.
How to open a new window Link
1. Window. Open ('url ')
2. Use udfs
< Script >
Function Openwin (TAG, OBJ)
{
Obj.tar get = " _ Blank " ;
OBJ. href = " Web/substation. aspx? Stationno = " + Tag;
OBJ. Click ();
}
</ Script >
< A Href = "Javascript: void (0 )" Onclick = "Openwin (3, this )" > Zhuzhou </ A >
3. Window. Location. href = ""
Conclusion: 1) the direct use of javascript: void (0) by Link (href) in IE may cause some problems, such as: causes the GIF animation to stop playing, the safest way is to use "#". To prevent the link from jump to the top, The onclick event return false. 2) Before using void (0), it is best to think about whether the page needs to be refreshed as a whole, and void (0) can be used when the page does not need to be refreshed as a whole ).
Window. Opener indicates to use window. Open to open a window to obtain the variable value of the parent window.