-4
我有一个视觉树中,我需要去申请剪切,复制和粘贴功能削减顶点,复制顶点和粘贴。 我想让代码在IE中工作。 有人能帮助我在代码剪切,复制和Java脚本粘贴。如何实现剪切,复制和粘贴功能在Javascript
由于提前
我有一个视觉树中,我需要去申请剪切,复制和粘贴功能削减顶点,复制顶点和粘贴。 我想让代码在IE中工作。 有人能帮助我在代码剪切,复制和Java脚本粘贴。如何实现剪切,复制和粘贴功能在Javascript
由于提前
了解更多关于Clipboard API and events
document.addEventListener('beforecopy', function(e){
if(weHaveDataToCopy()){ // use your web app's internal logic to determine if something can be copied
e.preventDefault(); // enable copy UI and events
}
});
document.addEventListener('copy', function(e){
e.clipboardData.setData('text/plain', 'Hello, world!');
e.clipboardData.setData('text/html', '<b>Hello, world!</b>');
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
});
document.addEventListener('paste', function(e){
if(e.clipboardData.types.indexOf('text/html') > -1){
processDataFromClipboard(e.clipboardData.getData('text/html'));
e.preventDefault(); // We are already handling the data from the clipboard, we do not want it inserted into the document
}
});