mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-06-08 16:48:09 +00:00
23 lines
406 B
JavaScript
23 lines
406 B
JavaScript
/*
|
|
* Copy current page url to clipboard.
|
|
*/
|
|
|
|
function copyLink(url, msg) {
|
|
if (!url || 0 === url.length) {
|
|
url = window.location.href;
|
|
}
|
|
|
|
const $temp = $("<input>");
|
|
$("body").append($temp);
|
|
$temp.val(url).select();
|
|
document.execCommand("copy");
|
|
$temp.remove();
|
|
|
|
let feedback = "Link copied successfully!";
|
|
if (msg && msg.length > 0) {
|
|
feedback = msg;
|
|
}
|
|
|
|
alert(feedback);
|
|
}
|