js禁止内容复制到app外面

JavaScript018

js禁止内容复制到app外面,第1张

方法

2:

在<body>中加入以下代码:

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

<body oncontextmenu="event.returnValue=false" onselectstart="event.returnValue=false">

实质上,方法2与方法1是一样的。

法3:

如果只限制复制,可以在<body>加入以下代码:

<body oncopy="alert('对不起,禁止复制!')return false">

2、使菜单"文件"-"另存为"失效

如果只是禁止了右键和选择复制,别人还可以通过浏览器菜单中的"文件"-"另存为"拷贝文件。为了使拷

贝失效,可以在<body>与</body>之间加入以下代码:

<noscript>

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

</noscript>

这样,用户在另存网页时,就会出现"无法保存Web页"的错误。

可以通过禁用浏览器的js功能来解除网页禁止粘贴,这里以谷歌浏览器为例。

1、同时按住键盘上的“Ctrl”键+“Shift”键+“Del”键打开谷歌浏览器的设置,然后点击页面底部的“高级”按钮:

/iknow-pic.cdn.bcebos.com/d01373f082025aafbd618226f5edab64024f1a8f"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/d01373f082025aafbd618226f5edab64024f1a8f?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/d01373f082025aafbd618226f5edab64024f1a8f"/>

2、点击“高级”按钮之后,在弹出的窗口中向下拉动,然后点击“网站设置”按钮:

/iknow-pic.cdn.bcebos.com/d31b0ef41bd5ad6e229298078fcb39dbb7fd3cf0"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/d31b0ef41bd5ad6e229298078fcb39dbb7fd3cf0?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/d31b0ef41bd5ad6e229298078fcb39dbb7fd3cf0"/>

3、在网站设置中找到“JavaScript”这一项,然后点击一项的按钮:

/iknow-pic.cdn.bcebos.com/9213b07eca8065389db958fe99dda144ac348288"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/9213b07eca8065389db958fe99dda144ac348288?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/9213b07eca8065389db958fe99dda144ac348288"/>

4、在弹出的页面中将JavaScript关闭,这时就解除了网页的禁止粘贴了:

/iknow-pic.cdn.bcebos.com/80cb39dbb6fd5266d5a7c0f9a518972bd507364a"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/80cb39dbb6fd5266d5a7c0f9a518972bd507364a?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/80cb39dbb6fd5266d5a7c0f9a518972bd507364a"/>

1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键,其实是禁止快捷菜单,因为不光右键可以弹出这个菜单,键盘上空格键右边的windows键也可以激活这个快捷菜单

<table border oncontextmenu=return(false)><td>no</table>可用于Table

2. <body onselectstart="return false">禁止选取、防止复制

3. onpaste="return false" 禁止粘贴

4. oncopy="return false" oncut="return false" 禁止复制和剪切

5. <input style="ime-mode:disabled">关闭输入法