html,用iframe,想实现自动粘贴(paste),发现有权限问题。请问除ctrl+v外,能不能通过其它的方法触发粘贴功能?
颜家大少 2017-10-25 11:30:44 现在做一个html富文本编辑器,用iframe
想实现自动粘贴,或通过点一个button触发粘贴,但发现在chrome\Firefox等浏览器上都不支持
用Document.queryCommandEnabled('paste')查询是不支持'paste'
除ctrl+v外,有没有其它的办法绕过这个权限问题?谢谢
参考代码如下:
$('#triggerPaste').click(function () {
var ifrm = document.getElementById("edit");
var doc = ifrm.contentDocument || ifrm.contentWindow.document;
doc.body.focus();//是编辑器获得焦点,防止代码插入在编辑器外地方
doc.execCommand('paste',false,null);
});