JQuery disables keyboard back shield F5 refresh and disable right-click, jqueryf5

Source: Internet
Author: User

JQuery disables keyboard back shield F5 refresh and disable right-click, jqueryf5

This document introduces four methods for jquery to disable multiple functions.

1. Disable F5 to refresh jQuery instance code
F5 has the ability to refresh the web page, and may sometimes need to disable this function. The following describes how to implement this function through code instances.
The Code is as follows:

$(document).ready(function(){  $(document).bind("keydown",function(e){   var e=window.event||e;   if(e.keyCode==116){    e.keyCode = 0;    return false;   }  }) })

2. jQuery disables shortcut keys such as keyboard rewind and F5 refresh

$ (Document ). keydown (function (event) {// mask Alt + direction key ↓ // mask Alt + direction key → if (event. altKey) & (event. keyCode = 37) | (event. keyCode = 39) {event. returnValue = false; return false;} // block the unsigned deletion key if (event. keyCode = 8) {return false;} // block the F5 refresh key if (event. keyCode = 116) {return false;} // block alt + R if (event. ctrlKey) & (event. keyCode = 82) {return false ;}});

3. Disable the right-click Function
The Code is as follows:

$(document).ready(function() { $(document).bind("contextmenu",function(e) { alert("sorry! No right-clicking!"); return false; }); }); 

4. jQuery's implementation code to prevent page bounce

$(document).keydown(function (e) { var doPrevent; if (e.keyCode == 8) { var d = e.srcElement || e.target; if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') { doPrevent = d.readOnly || d.disabled; } else doPrevent = true; } else doPrevent = false; if (doPrevent) e.preventDefault(); }); 

The above is all the content of this article, hoping to help you learn.

Articles you may be interested in:
  • Code for enabling and disabling server verification controls based on jquery
  • Jquery displays and hides elements or is set to read-only (controls with Ligerui are disabled. instance description)
  • Code forbidden by jquery batch control form
  • Jquery-based code for disabling right-click, Text Selection, and copying keys
  • Disable jquery right-click feature to block F5 refresh
  • Example of jquery disabling right-click
  • In-depth exploration of JavaScript and JQuery web page shielding right-click menu and prohibit select copy
  • Jquery's attr method disables form elements to disable input content
  • JQuery simply disables the right-click menu

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.