禁止选择文本和禁用右键 v3.0

禁止选中字体(注:在火狐浏览器没有起到效果作用)

<script>
function disableselect(e) {
    var omitformtags = ["input", "textarea", "select"];
    omitformtags = omitformtags.join("|");
    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()
}
</script>

 

posted @ 2016-10-16 11:22  林育松  阅读(164)  评论(0编辑  收藏  举报