禁止网页复制-另存-右键等

来源:互联网 发布:淘宝网页设计模板 编辑:程序博客网 时间:2024/05/01 15:35

如果你想你的网站内容不给人家复制,可以看看下面的实现方法:

//禁止鼠标右键

$(document).bind("contextmenu", function(e) {

    return false;

});

//禁止键盘按键:

<script type="text/javascript">

      function key() {

          if (event.shiftKey) {

              window.close();

          }

          //禁止Shift

          if (event.altKey) {

              window.close();

          }

          //禁止Alt

          if (event.ctrlKey) {

              window.close();

          }

          //禁止Ctrl

          return false;

      }

      document.onkeydown = key;

</script>

<!-- 禁止选中内容 -->

<script type="text/javascript">

    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

    } 

</script>

<!--禁止网页另存为: -->

<noscript>

    <iframe src="/*"></iframe>

</noscript>

JS禁止网页复制和拷贝,只需要在body中加入部分代码即可

<body oncontextmenu="return false" onselectstart="return false"  oncopy="return false">

还有另外一种方法,除了禁止另存外,其它功能基本上搞定:

<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false"

    onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"

onmouseup="document.selection.empty()">直接加在body标签里即可


0 0
原创粉丝点击