Enable the user to press enter on the webpage to automatically jump to the next control, and disable the use of the right-click and other shortcut keys of the HTC Control

Source: Internet
Author: User


// Function: enables the user to automatically jump to the next control by pressing enter on the webpage. right-clicking and other shortcut keys are prohibited.

// Method: Use the HTC component and the CSS file to bind the keydown event of the body to the custom function.

// Author: waxdoll Cheung

// Time:

// Memo: This is my first HTC file.

<Public: component lightweight = false>

<Public: attach event = "onkeydown" onevent = "enter2tab ()"/>

<Public: attach event = "oncontextmenu" onevent = "nocm ()"/>

<Public: attach event = "onhelp" onevent = "nohelp ()"/>

<Script language = "JavaScript">

Function enter2tab ()

{

// Press the Enter key to jump to the next input control

If (event. keycode = 13)

Event. keycode = 9;

/// Mask Alt + direction keys ↓ and ALT + direction keys →

If (window. event. altkey) & (window. event. keycode = 37) | (window. event. keycode = 39 )))

Event. returnvalue = false;

// Shield unrefresh key, F5 refresh key, CTRL + R, F11, CTRL + N, Shift + F10

If (event. keycode = 8) | (event. keycode = 116) | (event. ctrlkey & event. keycode = 82) | (event. keycode = 122) | (event. ctrlkey & event. keycode = 78) | (event. shiftkey & event. keycode = 121 ))

{

Event. keycode = 0;

Event. returnvalue = false;

}

// Block Alt + F4

If (window. event. altkey) & (window. event. keycode = 115 ))

Return false;

// Block shift and use the left mouse button to open a new webpage

If (window. event. srcelement. tagname = "A" & window. event. shiftkey)

Window. event. returnvalue = false;

}

// Shield the right-click menu

Function nocm ()

{

Event. returnvalue = false;

}

// Block the F1 key

Function nohelp ()

{

Return false;

}

</SCRIPT>

</Public: component>

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.