大众世界 world of demotic + 社区新动力

 找回密码
 注册会员
搜索
查看: 4246|回复: 0

[分享] jquery 禁止鼠标右键 键盘按键

[复制链接]
发表于 2013-4-16 10:38:38 | 显示全部楼层 |阅读模式
jquery 禁止鼠标右键 键盘按键
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
有一点区别
$('body').bind("selectstart",function(){return false;});
如果要在firfox也禁止复制的话就可以用
body {  
   -moz-user-focus:   ignore;  
   -moz-user-select:   none;  
}
来定义了
下面提供一些禁止键盘按键代码。
function key() {
if (event.shiftkey) {
window.close();
}
禁止了选取内容

var omitformtags = ["input", "textarea", "select"]
omitformtags = omitformtags.join("|")
function disableselect(e) {
if (omitformtags.indexof(e.target.tagname.tolowercase()) == -1)
return false
}
function reenable() {
return true
}
if (typeof document.onselectstart != "undefined")
document.onselectstart = new function("return false")
else {
document.onmousedown = disableselect
document.onmouseup = reenable
}
本教程所有函数参考
.ready( handler )
handlera function to execute after the dom is ready.

(document).ready()是如何实现的
if ( jquery.browser.msie && window == top ) (function(){  2     if (jquery.isready) return;  3     try {  4            document.documentelement.doscroll("left");  5       } catch( error ) {  6       settimeout( arguments.callee, 0 );  7        return;  8     }  9    // and execute any waiting functions 10    jquery.ready(); 11 })(); 12 13 ……14 15 jquery.event.add( window, "load", jquery.ready );
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Archiver|手机版|小黑屋|Wod Inc. ( 蜀ICP备20000008号-8

GMT+8, 2024-5-10 13:30 , Processed in 0.135994 second(s), 39 queries .

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表