Home > Web Front-end > JS Tutorial > Code to control the clipboard through JS under IE_javascript skills

Code to control the clipboard through JS under IE_javascript skills

WBOY
Release: 2016-05-16 18:48:02
Original
1015 people have browsed it

JavaScript can use the window.clipboardData object to process clipboard content
Save to the clipboard method setData(param1, param2)
param1: Data type text or URL, etc.
param2: Data content
From clipboard The method of reading data from the board is getdata(param1)
The method of clearing data is clearData(param1)
The following is an example demonstration


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

The following is another example implementation Select characters on the page and drag them to the text area
Note that the window.event.dataTransfer object can also handle clipboard content, but it can only be used in drag-and-drop operations

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute <script> function copyToClipboard() { var d=document.all("source").value; window.clipboardData.setData('text', d); } </script>]<script> function transferDrop() { window.event.srcElement.innerText = window.event.dataTransfer.getData("text"); window.event.returnValue = false; } function transferDrag() { window.event.dataTransfer.dropEffect = 'move'; window.event.returnValue = false; } </script>
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