", "upDate": "2021-05-28T13:41:21+08:00" }

onclick 如何设置中的属性

heaei 2005-09-18 08:42:15
有一个copy限制的文件
page.asp
原码示意如下
########################

.....
.....
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" oncontextmenu="return false;" oncopy="return false;" onselectstart="return false;">
'内容
......
......
......
</body>

我想在页面中设一下按钮 按下时将原来<body>中的内容改成<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" >使页面显示的东西可以copy
...全文
172 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxz7531 2005-09-19
  • 打赏
  • 举报
回复
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" oncontextmenu="return false;" oncopy="return false;" onselectstart="return false;">
'内容
......
......
......
<input type="button" value="test" onclick="f();">
</body>
<script>
function f(){
document.body.oncontextmenu=null;
document.body.oncopy=null;
document.body.onselectstart=null;

}
</script>
csdntzg 2005-09-19
  • 打赏
  • 举报
回复
在iframe上加上属性 id="001"

代码中交换"001"和"document"的位置,按钮代码改为

<input type="button" value="test" onclick="
001.document.body.oncopy=function(){return true;};
001.document.body.onselectstart=function(){return true;};
001.document.body.oncontextmenu=function(){return true;};">
xudong520100 2005-09-18
  • 打赏
  • 举报
回复
可以设置一个hidden变量iscopy,通过判断iscopy的值来设置oncopy的值,可以实现。
matrixy 2005-09-18
  • 打赏
  • 举报
回复
<input type="button" value="test" onclick="document.body.oncopy=function(){return true;}">

这样...

但是我看你还是也得先把onselectstart 这个事件也一起取消掉吧,不然人家如何复制,哈哈......
heaei 2005-09-18
  • 打赏
  • 举报
回复
谢谢楼上两位,可以实现现在又有新问题
我用<iframe>将要copy的网页内容包含到我的页面中来。
点test没有作用。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<table align=center width="100%" height=600>
<tr>
<td valign=top align=left>
<form name="form1" method="post" action="guodong.asp">
<input name="address" type="text" id="address" size="60">
<br>
<input type="submit" name="Submit" value="提交">
</form>
<br>
</td>
</tr>
<%
Address=Request("address")
Response.write address
%>
<tr>
<td height=600>
<iframe src="<%=address%>" width="100%" height=600 name=001></iframe>
</td>
</tr>
<tr>
<td>
<input type="button" value="test" onclick="document.001.body.oncopy=function(){return true;};document.001.body.onselectstart=function(){return true;};document.001.body.oncontextmenu=function(){return true;};">
</td>
</tr>
</table>

防copy页面示例:www.teaonweb.com/hnsy/web/1.htm


87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧