PHP复制URL及SRC属性标签及弹窗提醒

方案一: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小时内删除,不允许用于商业用途,否则法律问题自行承担。

(1)
打赏 微信扫一扫赞赏 微信扫一扫赞赏 支付宝扫一扫赞赏 支付宝扫一扫赞赏
上一篇 2023年1月13日
下一篇 2023年3月22日

相关推荐

发表回复

登录后才能评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

笔者期待与您共勉 · 互赢

有言必答、商务合作、有偿服务

QQ:点击这里给我发消息

邮件:it@xuxiaokun.com

线上沟通时间 ↓↓↓:

周一至周五 9:30 - 17:30

其余时间Mail或QQ我,有言必应。

244439232