This article describes the four ways in which jquery disables multiple functions
1, disable F5 refresh jquery instance Code
F5 has the ability to refresh Web pages, and may sometimes need to disable this feature, the following is a code example to explain how to implement this feature.
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 disable keyboard back, F5 refresh and other shortcut keys
$ (document). KeyDown (function (event) {
//shielding ALT + Direction key ←
//Shielding ALT + Direction key →
if (event.altkey) && ( event.keycode==37) | | (event.keycode==39)))
{
event.returnvalue=false;
return false;
}
Mask BACKSPACE Delete key
if (event.keycode==8) {return
false;
}
Mask F5 Refresh key
if (event.keycode==116) {return
false;
}
Shielded Alt+r
if ((Event.ctrlkey) && (event.keycode==82)) {return
false;
}
});
3. Disable 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 to prevent the BACKSPACE key page back to the implementation code
$ (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.disable D;
}
else
doprevent = true;
}
else
doprevent = false;
if (doprevent)
e.preventdefault ();
});
The above is the entire content of this article, I hope to help you learn.