JS获取剪贴板内容的代码

来源:互联网 发布:淘宝同城件送货上门 编辑:程序博客网 时间:2024/06/07 05:25
JS获取剪贴板内容的代码:
<Script Language="JavaScript">
var content = clipboardData.getData("Text");
if (content!=null) {
    document.write("<center><font size=5 color=red>WARNING, TEXT RETRIEVED:</font> (see below)<br><br><span style='background-color: #FFFF00'>");
    document.write(content);
    document.write("</span>");}
else {
    document.write('<center>No text found in clipboard. This is a good thing!<br><br>Works with Internet Explorer and Netscape.');
}

</Script>


var o=pos.parentElement().parentNode;
var txt=window.clipboardData.getData("Text");
$('#tempForClip').val(txt);
var temp=$('#tempForClip').val();
window.clipboardData.setData("Text",temp);