Created
July 2, 2019 02:44
-
-
Save kiinlam/4770bf110e89e6b0f2673d60350c70c4 to your computer and use it in GitHub Desktop.
document.execCommand("copy")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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