zoukankan      html  css  js  c++  java
  • 如何禁止复制网页内容?(javascript)

    用JAVA禁止复制网页内容

    <Script Language=javascript>
    function key(){

    //if(event.shiftKey){
    //window.close();}
    //禁止shift
    if(event.altKey){
    alert('禁止CTRL-C复制本贴内容');}
    //禁止alt
    if(event.ctrlKey){
    alert('禁止CTRL-C复制本贴内容');}
    //禁止ctrl
    return
    false;}
    document.onkeydown=key;
    if
    (window.Event)
    document.captureEvents(Event.MOUSEUP);
    //swordmaple
    javascript article.
    //from www.jx165.com
    //function
    nocontextmenu(){
    //event.cancelBubble = true
    //event.returnValue =
    false;
    //return false;}
    function norightclick(e){
    if
    (window.Event){
    if (e.which == 2 || e.which == 3)
    return
    false;}
    else
    if (event.button == 2 || event.button ==
    3){
    event.cancelBubble = true
    event.returnValue = false;
    return
    false;}
    }
    function Click(){
    alert('禁止右键粘贴本贴内容');

    window.event.returnValue=false;
    }
    document.oncontextmenu=Click;

    </Script>

    一个更简单的方法就是在<body>中加入如下的代码,这样鼠标的左右键都失效了.

    topmargin="0"
    oncontextmenu="return false" ondragstart="return false" onselectstart ="return
    false" onselect="document.selection.empty()" oncopy="document.selection.empty()"
    onbeforecopy="return false"
    onmouseup="document.selection.empty()"

    1.禁止网页另存为:在<body>后面加入以下代码:
    <noscript>
    <iframe
    src="*.htm"></iframe>
    </noscript>


    2.禁止网页内容复制.粘贴:在<body>中加入以下代码:
    <body
    onmousemove=\HideMenu()\ oncontextmenu="return false" ondragstart="return false"
    onselectstart ="return false" onselect="document.selection.empty()"
    oncopy="document.selection.empty()" onbeforecopy="return false"
    onmouseup="document.selection.empty()">

  • 相关阅读:
    Python 遍历文件 读取文件夹里面的所有文件
    生活 帝国霸略 辅助工具的实现
    生活 帝国霸略 更换账户登陆 电脑登陆iphone手机账户 电脑手机同步登陆
    Python 颜色检测
    Python 指定窗口截屏
    Python 图片裁剪
    Python 窗口查找
    ES5新增的数组方法
    ES5对象新增的方法
    谈谈对文档碎片的理解
  • 原文地址:https://www.cnblogs.com/Gieag/p/2286130.html
Copyright © 2011-2022 走看看