Home > Web Front-end > JS Tutorial > Use of javascript copy and paste and clipboardData_javascript skills

Use of javascript copy and paste and clipboardData_javascript skills

WBOY
Release: 2016-05-16 16:33:45
Original
1505 people have browsed it

window.clipboardData can realize copy and paste operations, its getData method can realize data reading, and the setData method can realize data setting

 <script language="javascript"> 
function readTxt() 
{ 
alert(window.clipboardData.getData("text")); 
} 
function setTxt() 
{ 
var t=document.getElementById("txt"); 
t.select(); 
window.clipboardData.setData('text',t.createTextRange().text); 
} 
</script> 
<input name="txt" value="测试"> 
<input type="button" value="复制" onclick="setTxt()"> 
<input type="button" value="读取" onclick="readTxt()">
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template