我想在Mozilla Firefox中禁用HTML页面内容的选择,复制和粘贴。我使用jQuery和JavaScript来禁用右键单击并复制,选择,粘贴HTML页面的内容,它在IE和Chrome中运行良好,但在Mozilla Firefox中无法正常工作。
我们可以在Mozilla Firefox中禁用复制,粘贴选项吗?有什么建议吗?
答案 0 :(得分:0)
只需在您的网页中复制并粘贴以下javascript:
<script language="javascript" type="text/javascript">
function disableselect(e) {
return false
}
function reEnable() {
return true
}
document.onselectstart = new Function("return false")
if (window.sidebar) {
document.onmousedown = disableselect // for mozilla
document.onclick = reEnable
}
function clickIE() {
if (document.all) {
(message);
return false;
}
}
document.oncontextmenu = new Function("return false")
var element = document.getElementById('tbl');
element.onmousedown = function () { return false; } // For Mozilla Browser
</script>
注意:如果以上代码不适用于Firefox,则在body标签中添加style =“ - moz-user-select:none”,需要与上述代码一起限制。
答案 1 :(得分:0)
尝试第一次用于块选择,第二次允许在textarea和输入字段中选择。
html,body{
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
-khtml-user-select: none;
}
input, textarea{
-webkit-user-select: text !important;
-moz-user-select: text !important;
-ms-user-select: text !important;
user-select: text !important;
-khtml-user-select: text !important;
}
答案 2 :(得分:-4)
A)将此代码应用于body标签
中的html文档中 ondragstart=’return false’ onselectstart=’return false’
- 禁用复制和粘贴
B)在关闭头标记
之前,在html文档中使用此脚本<script language=JavaScript>
var message=”Function Disabled! OR whatever text you want to show on right click”;
function clickIE4(){
if (event.button==2){ alert(message); return false; }
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function(“alert(message); return false”)
</script>
C)使用body标签中的css元素
为内容提供安全性EX:在css文件中
body {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
这是BASIC保护!高级用户可以通过在浏览器上禁用JavaScript或使用firebug轻松绕过它。