复制加版权
2012-1-30 11:10 Monday  

分类: Javascript 评论(85) 浏览(26659)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 3</title>
</head>
<body>
<script language="javascript">
document.body.oncopy = function ()   //当发生复制事件时触发函数,不管是ctrl+c还是右键-复制
{  
     setTimeout(  
         function ()  
         {  
             var text = clipboardData.getData("text");  
             if (text)  
             {  
                 text = text + "\r\n该文章转载自blog:"+location.href;  
                 clipboardData.setData("text", text);  
             }  
         },  
         100  
     )  
}  
window.onload = function()  
{  
     this.focus();    //内容加载完成后,获取焦点
}
</script>
sdfsdfsdf
</body>
</html>

+1 11

留下你的看法: