示例代码如下:
<script type="text/javascript">
document.body.oncopy = function() {
event.returnValue = false;
var t = document.selection.createRange().text;
var s = "\r\n本文来源于:程序食堂[www.lmwlove.com]\r\n原文地址:" + window.location;
clipboardData.setData('Text', '\r\n' + t + '\r\n' + s + '\r\n');
}
</script>
要注意该代码要放在Body标签后面,不然会报document.body 为空的错误