本文实例讲述了JS实现获取剪贴板内容的方法。分享给大家供大家参考,具体如下:
这里介绍了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);
希望本文所述对大家JavaScript程序设计有所帮助。