web| Solution | control | Page Resolution "Focus control" method on Web page
For b/S system, in the page control than the C/s system so flexible control, such as the input focus of the problem, customers are very interested in data entry through the keyboard, such a request I think 100 customers will have 90.
Therefore, it is necessary to solve the problem of focus acquisition. We can find some methods on the Internet, but all the trouble, I now introduce a very convenient. The effect is also very good method for everyone.
I looked at MS's asp.net lectures some time ago, in which I talked about how to get the "enter" to move the focus of the text box down. One of the three methods, the best one is this:
Using client script to add the document's onkeydown event to the page, let the page perform the TAB function after receiving the carriage return event, that is, just change the event's KeyCode from 13 to 9
This way of handling, can realize the focus of moving down, but for the button also plays the same role, the general customer after entering the data, jump to the button, it is best to directly press "enter" to submit data. Therefore, the above method should be modified to the "submit" The button does not shift focus. Direct activation commits.
So I made a modification to the above code, that is, to determine the "source" of the event, is the Submit button, the code is as follows:
To determine if it is a button, because there will be a type= "button" on the HTML
To decide whether to submit, because the HTML will have type= "submit"
To determine if reset is because the "reset" on HTML should be executed
To determine whether it is empty because the "<a> link" on HTML should also be executed, this situation is not much, you can use the "Tabindex=-1" way to cancel the link to get focus.
This is my personal point of view, I was in the ASP.net system development, I will put this client script in "BasePage", other pages will inherit him, so you can control in many pages. If there are other good ways, I hope you will discuss.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service