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
]
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
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>