方案一:URL链接复制
function copy(url) {
$.growl.notice({
title: "复制成功",
message: "链接已被复制!"
});
var aux = document.createElement('input');
var content = url;
aux.setAttribute('value', content);
document.body.appendChild(aux);
aux.select();
document.execCommand('copy');
document.body.removeChild(aux)
}
方案二:
function copyToClip(content, message) {
var aux = document.createElement("input");
aux.setAttribute("value", content);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
if (message == null) {
toast({
title: 'Hi',
description: '复制成功',
type: 'success',
timeout: 1500,
radius: 3
});
} else {
alert(message)
}
}
function success() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: '复制成功',
type: 'success',
timeout: 5000
})
}
function error() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Error message',
type: 'error',
timeout: 5000
})
}
function warning() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Warning message',
type: 'warning',
timeout: 5000
})
}
function custom() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Custom message',
type: 'custom',
close_color: '#3498db',
border_color: '#3498db',
timeout: 5000
})
}
方案三:
function copyToClip(content, message) {
var aux = document.createElement("input");
url = content.replace("/", "");
dir = window.location.pathname;
dir = dir.replace("index.php", "");
dir = dir.slice(1);
url = dir + url;
var index1 = url.lastIndexOf(".");
var index2 = url.length;
var suffix = url.substring(index1 + 1, index2);
var msg = '链接已复制';
switch (suffix) {
case 'js':
url = "<script src = '" + url + "'></script>";
msg = "复制Scrip标签成功";
break;
case 'css':
url = "<link rel='stylesheet' href='" + url + "'>";
msg = "复制Link标签成功";
break;
default:
if ((suffix == 'jpg') || (suffix == 'jpeg') || (suffix == 'gif') || (suffix == 'bmp') || (suffix == 'png') || (suffix == 'ico')) {
url = "<img src = '" + url + "' />"
msg = "复制HTML标签成功";
} else {
url = url
}
break;
}
aux.setAttribute("value", url);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
if (message == null) {
toast({
title: 'Hi',
description: msg,
type: 'success',
timeout: 1500,
radius: 3
})
} else {
alert(message)
}
}
/* 消息提醒 */
/* 如果调用此处,调用:<script src="/static/jquery-mac-message-tips/hullabaloo.js"></script> 提醒请用:$.hulla.send("Hi!复制成功!", "success"); */
// $.hulla = new hullabaloo();
function success() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: '复制成功',
type: 'success',
timeout: 5000
})
}
function error() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Error message',
type: 'error',
timeout: 5000
})
}
function warning() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Warning message',
type: 'warning',
timeout: 5000
})
}
function custom() {
init({
fade_in: 800,
fade_out: 800,
position: 'top-center'
});
toast({
title: 'Hi',
description: 'Custom message',
type: 'custom',
close_color: '#3498db',
border_color: '#3498db',
timeout: 5000
})
}
方案四:
请输入口令查看完整内容
历史上的今天
2015年:最伟大的教育,竟然是妈妈的情绪平和!(0条评论)
请博主喝杯咖啡呢,谢谢^_^
如果本文“对您或有帮助”,欢迎随意打赏,以资鼓励继续创作!
原创文章《PHP复制URL及SRC属性标签及弹窗提醒》,作者:笔者 徐哲,未经允许不得转载。
转载或复制时,请注明出处:https://www.xuxiaokun.com/2983.html,本文由 Mr.xu 博客网 整理。
本站资源下载仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。