Solve the "Focus Control" one on the web page
For B / S systems, it is not as good as the C / S system on page control. If the input focus problem, the customer wants to enter the data via the keyboard, so I want 100 customers, there will be 90 Bar.
Therefore, it is necessary to resolve the focus acquisition problem. You can find some ways from the Internet, but it is more troublesome, I now introduce a very convenient. The effect is also very good. Method for everyone.
I saw the ASP.NET lecture of MS for some time. I talked about how to let the "Enter key" to move the focus of the text box. One of them, the best one is this:
Use the client script to add Document's onkeyDown event on the page, so that the page is accepted after receiving the carriage return, that is, as long as the Event's KeyCode is changed from 13 to 9
VBScript code:
Sub Document_onkeyDown
if Event.Keycode = 13 THEN
Event.Keycode = 9
END IF
End Sub
script>
The JavaScript code is as follows:
Event.keycode == 13)
Event.Keycode = 9;
->
script>
In this way, the focus can be moved down, but the same role is also possible, and the general customer will be submitted directly to the "Enter" after entering the button after entering the information. To make a modification of the above method, you should do not focus transfer for the "Submit" button. Direct activation.
So I made a modification of the code above, that is, the "source" of the event, whether the submission button is submitted, the code is as follows:
IF (event.keycode == 13 && event.srcelement.Type! = 'button' && event.srcelement.type! = 'Submit' && event.srcelement.Type! = 'reset' && round.srcelement.type! = ' ')
Event.Keycode = 9;
->
script>
Judging whether it is Button because there will be type = "button" on HTML.
Judging whether it is submit, because there will be type = "submit" on HTML
Judging whether it is reset because "reset" on HTML should be executed
The determination is empty because " link" on HTML should also be executed, and this situation occurs, and "tabindex = -1" can be used to cancel the chain to obtain focus.
The above is my personal point of view, I am in the ASP.NET, I will put this client script in "basepage", and other pages will inherit him, so that there can be controls in many pages. If there are other good Measures, I hope everyone will discuss it.
Listen to
2004-5-13
Tintown_liu@hotmail.com
Blog: http://tintown.blogbus.com