如何在html中禁止文字的复制

如何在html中禁止文字的复制,第1张

在<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 leftmargin=0 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()'>

禁止复制

οncοntextmenu='return false'    //禁止右键

οndragstart='return false'    //禁止拖动

onselectstart ='return false'    //禁止选中

οnselect='document.selection.empty()'    //禁止选中

οncοpy='document.selection.empty()'    //禁止复制

onbeforecopy='return false'   // 禁止复制

οnmοuseup='document.selection.empty()'

*{

  moz-user-select: -moz-none

  -moz-user-select: none

  -o-user-select:none

  -khtml-user-select:none

  -webkit-user-select:none

  -ms-user-select:none

  user-select:none

}

长按事件document.addEventListener("touchstart", function (e) {     console.log('touchstart')     timer = setTimeout(function () {         console.log('LongPress')         e.preventDefault()         LongPress(parentObj)     }, 800) }) document.addEventListener("touchmove", function (e) {     console.log('touchmove')     clearTimeout(timer)     timer = 0 }) document.addEventListener("touchend", function (e) {     console.log('touchend')     clearTimeout(timer)     if (timer != 0) {         alert('这是点击,不是长按')     }     return false })

1、第一种方法就是利用快照功能,现在的几大搜索引擎都有自己的快照功能,遇到了不能复制的情况,我们可以点击网站右下角的“快照”试试。

2、如果以上方法依旧不行,那么在浏览器上方找到“查看”-“查看网页源代码”,可能浏览器不同的话叫法也有区别,不过全部都有源代码选项的。

3、通过以上我们也发现了,源代码页面除了有我们需要的文字内容以外,还有乱七八糟的各种代码和符号,虽然可以复制了,但是网页上的格式已经面目全非,所以不到迫不得已还是没必要使用这个方法。

4、那么最后一个基本上就能解决大多数情况了,我们首先找到要复制网页的网址,然后将其粘贴到IE浏览器地址栏。

5、接下来依次点击“文件”-“使用Word2013编辑”(根据电脑里按照的对应显示),然后刚才网页里的所有内容就复制到了Word文档下,这样我们即可随意进行复制粘贴了。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7942259.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-11
下一篇2023-04-11

发表评论

登录后才能评论

评论列表(0条)

    保存