document.execCommand paste not working in contentEditable div
document.execCommand
paste not working, i.e it works only when a selection has been made and it replaces the selected contents, otherwise no change is made. By the way I am using a contenteditable
div element where I am trying to do this.
In all browsers it fails, I am using it on clicking a particular li
element of a ul
.
<ul>
<li>
<a href="javascrip开发者_StackOverflow社区t:void(0)"onclick="paste();"><span>Paste</span></a>
</li>
</ul>
Where paste is the function where I use: document.execCommand('paste',false,null);
Mozilla (Opera too) requires special security setting.
Browsers compatibility.
Check this (preferably in IE). While you click the link, the focus is changing and the browser wants to paste data into that link. I hope it will help you.
精彩评论