(已解决)关于js如何抑制键盘功能键ctrl、shift 不可用

0
经过大神帮助,虽然有点瑕疵,不过还是基本解决了问题。故贴出此段js分享(弹出透明遮挡层来解决)、、、、、


<script type="text/javascript">
var currKey=0;
var flag=true;
document.onkeydown=function(){
var e = event;
currKey = e.keyCode || e.which || e.charCode;
if(currKey==17||currKey==16){
if(flag){
divMessageBox()
}
}
};

var bgObj ="";
function divMessageBox()
{
flag=false;
var iWidth = document.body.clientWidth;
var iHeight = document.body.clientHeight;
bgObj = document.createElement("div");
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=0);opacity:0;background-color:#000000;z-index:101;";
document.body.appendChild(bgObj);
}

document.onkeyup = function(){
flag=true;
document.body.removeChild(bgObj);
}
</script>
已邀请:
0

梁勇 - 天道酬勤、上善若水。爱好商业智能 2013-11-11 回答

Good,谢谢分享,赞一下

要回复问题请先登录注册