Solution to avoid meaningless page refresh caused by the Enter key
Updated: April 12, 2011 00:12:48 Author:
I believe everyone has encountered similar problems in the process of realizing local refresh of the page: after entering the key fields to search in the text box, press Enter to get the entire page refreshed, and the local refresh will definitely fail.
A careful analysis of such pages generally meets the following conditions:
1. Include FORM form
2. There is only one text box
This way the problem can be solved, just break any of the conditions. The general approach is to add a hidden text box
Of course, you can also add an onsubmit event after the form form and return false to prevent form submission
1. Include FORM form
2. There is only one text box
This way the problem can be solved, just break any of the conditions. The general approach is to add a hidden text box
Of course, you can also add an onsubmit event after the form form and return false to prevent form submission
Related Articles
JavaScript Image object implementation principle instance analysis
This article mainly introduces the example analysis of JavaScript Image object implementation principle. The example code is introduced in this article in detail, which has certain reference learning value for everyone's learning or work. Friends who need it can refer to it.2020-08-08Promise literacy post
This article mainly introduces the Promise literacy post. The example code is introduced in very detailed, which has certain reference and learning value for everyone's study or work. Friends who need it, please learn with the editor below.2019-06-06Magical code kills all kinds of websites - you can modify and copy the content of the page at will
Enter this line of code in the browser address bar, then press Enter, and you will find that the entire page can be edited at will. Just a short line of code.2008-07-07Three ways to implement network requests by JS
This article mainly introduces the writing methods of asynchronous network requests based on XMLHttpRequest, Promise, async/await, etc. The sample code in the article is explained in detail. If you are interested, you can learn it.2022-03-03js simple pop-up box with close button
This article mainly introduces a simple pop-up box made using js and has a close button. Friends who need it can refer to it.2014-05-05Several methods and verifications for submitting forms using JS (must-read)
Below, the editor will bring you several methods and verifications for submitting forms using JS (must-read). The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2016-09-09JS front-end image optimization compression scheme
This article mainly introduces the JS front-end image optimization compression solution. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase as soon as possible.2022-09-09Several registry settings for server security settings
Several registry settings for server security settings...2007-07-07Detailed explanation of 4 methods and principles of javascript across domains
The js cross-domain mentioned here refers to data transmission or communication between different domains through js, such as using ajax to request data from a different domain, or obtaining data from a framework of different domains in the page through js. As long as there is any difference in the protocol, domain name, or port, it is regarded as a different domain.2014-04-04''var'' in JScript defines the scope of a variable
''var'' in JScript defines the scope of a variable...2007-03-03