绿野仙踪's Archiver

阿喀琉斯 发表于 2008-3-22 14:08

文章被复制时自动加入版权信息(文字水印)的两种方法

方法一、[code]<script type="text/javascript">
n-TU"UHw document.body.oncopy = function () {
r"v bCeb hW Y         setTimeout( function () { G }4C3X@~&j2Y,w1~ Ep
                var text = clipboardData.getData("text");g Q&t0{O0n5_
                if (text) {
7`X-ciV o7B`                         text = text + "\r\n 【温馨提示】本文转载自: "+location.href; clipboardData.setData("text", text);+_XrtW:wy(jvdI
                }
9~e zv @;L                                 }, 100 ) 9MaJ*R9s9@^
} u'Q;kL:zbh
</script>[/code]测试结果: Maxthon下不弹出提示,IE7和IE6下会弹出提示。Firefox下无效。
3g{&Ur8x,@/I+p
1s(G)b)mw Q 方法二、[code]<script type="text/javascript">
Y@4j!G@H         document.body.oncopy = function() {#|X"M-N%nPsRr G
                event.returnValue = false;
c|r\(h `2` I:H                 var t = document.selection.createRange().text;^:s pF(ia,m
                var s = "【温馨提示】本文转载自: "+top.window.location.href;
'dk3f`R W[s                 clipboardData.setData('Text',t+'\r\n'+s+'\r\n\r\n\r\n');
4bi X,l9f`         }})~P5Z/D V
</script>[/code]测试结果: Maxthon和IE7下不弹出提示,IE6下会弹出提示。Firefox下无效。

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.