我在false
成功回调中尝试了以下内容,但它失败并返回document.execCommand('copy')
。在 Edge 浏览器中会出现此问题。
<div id="toCopy">
new value 12345
<br /><br />
<a href="#">Link</a>
</div>
HTML代码:
toCopy = Backbone.Model.extend({});
toCopy.fetch({
"id": "xxx",
}).done(function(resp) {
if (window.getSelection) {
var range = document.createRange();
range.selectNodeContents(document.getElementById("toCopy"));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
document.execCommand("copy");
});
Backbone JS代码:
ApplicationController