JavaScript masking f5,backspace and other keys

Source: Internet
Author: User
Tags delete key

Java code
  1. function DisableF5 () {
  2. With (event) {
  3. //F5 and Ctrl+r
  4. if (keycode==116 | | (Ctrlkey && keycode==82)) {   
  5. Event.keycode = 0;
  6. Event.cancelbubble = true;
  7. return false;
  8. }
  9. }
  10. }
  11. Document.onkeydown = DisableF5;

Java code

  1. function Document.onkeydown ()
  2. {
  3. if ((event.keycode==8) | | //Mask BACKSPACE delete key
  4. (event.keycode==116) | | //Shielded F5 Refresh key
  5. (Event.ctrlkey && event.keycode==82)) { //ctrl + R
  6. event.keycode=0;
  7. Event.returnvalue=false;
  8. }
  9. }


One, JS Screen browser (ie and Firefox) refresh function

Java code
  1. Document.onkeydown=function ()
  2. {
  3. if ((window.event.keycode==116) | | //Shielded F5
  4. (window.event.keycode==122) | | //Shielded F11
  5. (Window.event.shiftKey && window.event.keycode==121) //SHIFT+F10
  6. )
  7. {
  8. window.event.keycode=0;
  9. Window.event.returnvalue=false;
  10. }
  11. if ((Window.event.altKey) && (window.event.keycode==))
  12. {
  13. //Shielded Alt+f4
  14. Window.showmodelessdialog ("About:blank", "" "," dialogwidth:1px;dialogheight:1px ");
  15. return false;
  16. }
  17. }



Second, JS Screen browser right-click function

Java code
    1. if (window. Event)
    2. Document.captureevents (Event.mouseup);
    3. function Nocontextmenu ()
    4. {
    5. Event.cancelbubble = true
    6. Event.returnvalue = false;
    7. return false;
    8. }
    9. function Norightclick (e) {
    10. if (window. Event) {
    11. if (E.which = = 2 | | e.which = = 3)
    12. return false;
    13. }
    14. Else
    15. if (Event.button = = 2 | | event.button = = 3) {
    16. Event.cancelbubble = true
    17. Event.returnvalue = false;
    18. return false;
    19. }
    20. }
    21. Document.oncontextmenu = Nocontextmenu; //For ie5+
    22. document.onmousedown = norightclick; // for all others   
Related Article

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.