js控制ctrl+p

1.LI中内容超过长度后以省略号显示的方法
<style type="text/css">
<!--
li {
width:200px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}

-->
</style>
<ul>
<li><a href="#">拉萨酱豆腐里脚手道路 上水道法撒旦法 </a></li>
</ul>

2.鼠标右键得屏蔽以及快捷键得评比

<body oncontextmenu="return false" onkeydown="bodyOnKeyDown()">
function bodyOnKeyDown(){

var actObjTagName = "";
var actObjType = "";
try{
actObjTagName = document.activeElement.tagName.toLowerCase();
actObjType = document.activeElement.type.toLowerCase();
}catch(e){
}
/*
//ENTER->TAB
if( event.keyCode==13 &&
actObjType!="button" &&
actObjType!="submit" &&
actObjType!="reset" &&
//actObjType!="textarea" &&
actObjTagName!="a"){
event.keyCode = 9;
}
*/

//Function Key
if(event.ctrlKey){
if( event.keyCode==78 || //CTRL+N
event.keyCode==87 || //CTRL+W
event.keyCode==69 || //CTRL+E
event.keyCode==73 || //CTRL+I
event.keyCode==79 || //CTRL+O
event.keyCode==80 || //CTRL+P
event.keyCode==76 || //CTRL+L
event.keyCode==72 || //CTRL+W
event.keyCode==66 ){ //CTRL+B
event.keyCode = 0;
event.returnValue = false;
}
}

if( event.keyCode>=112 && //F1,F12
event.keyCode<=123 ){
event.keyCode = 0;
event.returnValue = false;
}

if( event.keyCode==27 ){ //ESC
event.keyCode = 0;
event.returnValue = false;
}

if( event.keyCode==8){ //Backspace
if( actObjType!="text" &&
actObjType!="textarea" &&
actObjType!="password" &&
actObjType!="file"){
event.keyCode = 0;
event.returnValue = false;
}
}

}

转载:http://www.blogjava.net/hotcup/archive/2006/12/04/85425.aspx

JS技巧:http://www.blogjava.net/hotcup/archive/2006/09/17/70103.html

你可能感兴趣的:(js)