网站添加复制时弹出对话框版权提醒今天整理了下,又结合了网上其他的教程,一块发出来,也作为自用备用!
第一种:最原始的不借助任何插件

<script type=”text/javascript”>
document.body.oncopy=function(){
alert(“复制成功!站咖网提醒您:若要转载请保留原文链接,谢谢合作!”);
}
</script>
第二种:对第一种的美化,前两种都是需要点确定的,要加载sweetalert

<link rel=”stylesheet” href=”https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css” />
<script type=”text/javascript” src=”https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js”></script>
<script type=”text/javascript”>
window.onload = function(){
document.body.oncopy = function() {
swal(“复制成功!”, “站咖网提醒您:若要转载请保留原文链接,谢谢合作!”,”success”);
};
}
</script>
第三种:用的layui,弹窗3秒自动消失,用layer就可以根据需要换弹窗样式了,比如说加个icon啥的

<script src=”http://libs.baidu.com/jquery/2.1.4/jquery.min.js”></script>
<script src=”layer/layer.js”></script>//layer自己去官网下载就可以
<script type=”text/javascript”>
document.body.oncopy = function() {layer.msg(‘复制成功,站咖网提醒您:若要转载请务必保留出处!’);};
</script>
