Skip to content

Instantly share code, notes, and snippets.

@kiinlam
Created July 2, 2019 02:44
Show Gist options
  • Save kiinlam/4770bf110e89e6b0f2673d60350c70c4 to your computer and use it in GitHub Desktop.
Save kiinlam/4770bf110e89e6b0f2673d60350c70c4 to your computer and use it in GitHub Desktop.
document.execCommand("copy")
n.copy = function(e, n, o) {
var c = d('<span class="my-gallery-src-copy-hidden">' + e + "</span>")
, s = d("body");
s.append(c);
var a = document.createRange();
a.selectNode(c.get(0));
var i = window.getSelection();
i.removeAllRanges(),
i.addRange(a);
var t = document.execCommand("copy");
c.remove(),
n && n(t),
o && (s.find(".kb-g-copy-success-info").remove(),
clearTimeout(p),
s.append(d('<span class="kb-g-copy-success-info">\u590d\u5236\u6210\u529f</span>').css({
position: "fixed",
top: o.y - 50,
left: o.x - 10,
"z-index": 1e6
})),
p = setTimeout(function() {
s.find(".kb-g-copy-success-info").remove()
}, 1e3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment