var omitformtags=["input","textarea", "select"];//过滤掉的标签
omitformtags = omitformtags.join("|")
/**
* 禁止鼠标选中
* @param {Object} e
* @return {TypeName}
*/
function disableselect(e){
var e = e || event;//IE 中可以直接使用 event 对象 ,FF e
var obj = e.srcElement ? e.srcElement : e.target ;//在 IE 中 srcElement 表示产生事件的源,FF 中则是 target
if(omitformtags.indexOf(obj.tagName.toLowerCase())==-1){
if(e.srcElement){//IE
document.onselectstart=new Function ("return false");
}
return false;
}else{
if(e.srcElement){//IE
document.onselectstart=new Function ("return true");
}
return true;
}
}
function reEnable(){
return true
}
/*if(typeof document.onselectstart!="undefined"){//IE Chrome null
document.onselectstart=new Function ("return false") //onselectstart="return false" 取消选取、防止复制
}else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}*/
function stop(){
return false;
}
document.onmousedown=disableselect;//按下鼠标上的设备(左键,右键,滚轮……)
document.onmouseup=reEnable;//设备弹起
document.oncontextmenu=stop;//屏蔽鼠标右键
//onpaste="return false" 不准粘贴
// oncopy="return false;" oncut="return false;" 防止复制
转载于:https://my.oschina.net/zhk/blog/150299