In a depressing situation, an event of automatic Ajax sending by carriage return is added to a text element on the page. However, every time you press enter, it will automatically submit the form and refresh the page, simple page htmlCodeAs follows:
Code < Html >
< Head >
< Title > Test </ Title >
< Script Language = "JavaScript" >
Function Test (){
If (Event. Which | Event. keycode ){
If (Event. Which = 13 | Event. keycode = 13 ){
Ajaxpost ();
Return False ;
} Else {
Return True ;
}
}
}
</ Script >
</ Head >
< Body >
< Form Name = "Test" Method = "Post" Action = "Test.htm" >
< Input Type = 'Button' Value = 'Test' Onclick = "Javascript: Test ()" >
< Input Type = "Text" Name = "Textfield" Class = "Input" >
</ Form >
</ Body >
</ Html >
In order to solve this problem, neither of the following methods can be used to block the event or return false. Later, I checked it on the Internet. It turns out that this is a default operation of IE (but it is strange that the same is true in Firefox ). The solution is simple. You only need to add a text element to the page, which can be hidden.