禁止粘贴复制功能问题
我已经在 <body> 标签里面加了禁止粘贴与复制功能,为什么在 <iframe> 里面还是可以复制和粘贴呢?我希望禁止它的复制粘贴功能,请问有什么办法吗?代码如下,请各位达人帮助。
<script>
function document.onreadystatechange()
{
show_text.document.designMode= "On ";
show_type.document.designMode= "On ";
}
</script>
<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() ">
<IFRAME id=show_text style= "WIDTH: 100%; HEIGHT: 296px " marginWidth=0 marginHeight=0>
</IFRAME>
<IFRAME id=show_type style= "WIDTH: 100%; HEIGHT: 296px " marginWidth=0 marginHeight=0>
</IFRAME>
</body>
------解决方案--------------------IFRAME是属于另一个WINDOW对象了,你得在它里面进行禁止.
document.getElementById( "show_text ").contentWindow.document.oncopy = function()
{
return false;
}
------解决方案--------------------在iframe引用的那一页加上你这一段
<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() ">
或者在iframe的style属性里加上
style= "-moz-user-select:none;/*For FF*/
select:expression(this.onselectstart=function(){return(false)});/*For IE*/
copy:expression(this.onmousemove=function(){var tR=document.selection.createRange(), temp=tR.collapse(), temp= tR.select() });/*For IE*/ "
IE和FF都不能复制框选了