admin管理员组文章数量:1026989
I tried to create a RichText Editor using jQuery with the help of execCommand().
But the following code:
document.execCommand('cut', false, null);
document.execCommand('copy', false, null);
document.execCommand('paste', false, null);
Is not working in Mozilla Firefox, Google Chrome and some other browsers.
Are there any possibilities to do the Cut, Copy and Paste actions using execCommand() or there is any other method to do the Cut, Copy and Paste actions in my RichText Editor?
I tried to create a RichText Editor using jQuery with the help of execCommand().
But the following code:
document.execCommand('cut', false, null);
document.execCommand('copy', false, null);
document.execCommand('paste', false, null);
Is not working in Mozilla Firefox, Google Chrome and some other browsers.
Are there any possibilities to do the Cut, Copy and Paste actions using execCommand() or there is any other method to do the Cut, Copy and Paste actions in my RichText Editor?
Share edited Jan 24, 2016 at 17:19 Julien Grégoire 17.1k4 gold badges33 silver badges61 bronze badges asked Mar 13, 2015 at 5:22 Developer StrangeDeveloper Strange 2,1988 gold badges33 silver badges47 bronze badges2 Answers
Reset to default 3It's easy to solve this problem, follow these steps: Go to "about:config" no quotes on Firefox and then hit the "i'll be careful, I promise" button, next type "dom.event.clipboardevents.enabled" then double click it, so the value is false. And that should do the trick.
From Chrome 42 and Firefox 41, document.execCommand('cut') and document.execCommand('copy') will work, but only on semi trusted events. See here https://www.w3/TR/2014/WD-clipboard-apis-20140313/#semi-trusted-events
Like this for example:
document.getElementById('copy').onmousedown = function() {
console.log(document.execCommand('copy'))
}
document.getElementById('cut').onmousedown = function() {
console.log(document.execCommand('cut'))
}
<textarea></textarea>
<button id="copy">Copy</button>
<button id="cut">Cut</button>
On Chrome document.execCommand('paste') will work the same way but requires an extension to be installed to allow it. Without extension, it won't work. To allow it, you need to include this "clipboarRead" in the permissions in your manifest.json file. Like this:
permissions: {
...
"clipboardRead"
...
}
I tried to create a RichText Editor using jQuery with the help of execCommand().
But the following code:
document.execCommand('cut', false, null);
document.execCommand('copy', false, null);
document.execCommand('paste', false, null);
Is not working in Mozilla Firefox, Google Chrome and some other browsers.
Are there any possibilities to do the Cut, Copy and Paste actions using execCommand() or there is any other method to do the Cut, Copy and Paste actions in my RichText Editor?
I tried to create a RichText Editor using jQuery with the help of execCommand().
But the following code:
document.execCommand('cut', false, null);
document.execCommand('copy', false, null);
document.execCommand('paste', false, null);
Is not working in Mozilla Firefox, Google Chrome and some other browsers.
Are there any possibilities to do the Cut, Copy and Paste actions using execCommand() or there is any other method to do the Cut, Copy and Paste actions in my RichText Editor?
Share edited Jan 24, 2016 at 17:19 Julien Grégoire 17.1k4 gold badges33 silver badges61 bronze badges asked Mar 13, 2015 at 5:22 Developer StrangeDeveloper Strange 2,1988 gold badges33 silver badges47 bronze badges2 Answers
Reset to default 3It's easy to solve this problem, follow these steps: Go to "about:config" no quotes on Firefox and then hit the "i'll be careful, I promise" button, next type "dom.event.clipboardevents.enabled" then double click it, so the value is false. And that should do the trick.
From Chrome 42 and Firefox 41, document.execCommand('cut') and document.execCommand('copy') will work, but only on semi trusted events. See here https://www.w3/TR/2014/WD-clipboard-apis-20140313/#semi-trusted-events
Like this for example:
document.getElementById('copy').onmousedown = function() {
console.log(document.execCommand('copy'))
}
document.getElementById('cut').onmousedown = function() {
console.log(document.execCommand('cut'))
}
<textarea></textarea>
<button id="copy">Copy</button>
<button id="cut">Cut</button>
On Chrome document.execCommand('paste') will work the same way but requires an extension to be installed to allow it. Without extension, it won't work. To allow it, you need to include this "clipboarRead" in the permissions in your manifest.json file. Like this:
permissions: {
...
"clipboardRead"
...
}
本文标签:
版权声明:本文标题:javascript - why Cut,Copy,Paste is not working in Mozilla Firefox and Google Chrome browser? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1744651110a2108900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论