Web page prevents the TAB key from using a quick fix _javascript tips

Source: Internet
Author: User

In some Web pages or the use of the pop-up layer, the general situation in IE browser we do not want to use the tab or say

When you use the TAB key, you can create problems, such as:

After the pop-up layer, the TAB key can also be manipulated in the page, which results in a script error.

So what if we avoid this?

Controlling by keyboard events

Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" src= ". /javascript/jquery-1.2.6.min.js "></script>
    <script language=" javascript "type=" Text/javascript ">
        $ (document). Ready (function () {
             $ (document). Bind (' KeyDown ', function (event) {
                if (Event.keycode = 9) {
                     Document.body.focus ();
               }
           });
       });
    </script>

The above code is very familiar is to press the TAB key when the focus moved again to the top of the TabIndex 0

Then we need to set the initialization page focus at the beginning of the page.

For example, the following example is written in aspx:

<box:button id= "btnclose" text= "Off" runat= "server" systemicon= "close" tabindex= "0" focusonpageload= "true" >
</box:Button>

In some special cases we need to set the focus position when the page is loaded in order to prevent the TabIndex setting from appearing invalid or affected by other factors.

So that you can be foolproof!

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.