点击文字等超链接时弹出层(可用于弹出二维码或图片广告等)
代码原作者网站可运行演示
https://www.layui.com/doc/modules/layer.html
下面用于点击文字超链接弹出二维码的代码
首先需要在网站页面加入两个公共js ↓
- <script src = "https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
- <script src = "https://cdnjs.cloudflare.com/ajax/libs/layer/3.1.1/layer.js"></script>
复制代码
js代码;
- <script>
- var myjq = jQuery.noConflict();
- function dshow(qrcode, url, title, comment) {
- layer.open({
- type: 0,
- title: title,
- content: '<img src = "'+qrcode+'" width = "200px" height = "200px"/><br /><b style = "color: #F00;">'+comment+'</b>',
- area:['320px', '360px'],
- btn: '进入链接',
- yes: function(index) {
- layer.close(index);
- location.href = url;
- },
- });
- }
- </script>
复制代码
css样式代码;
- <style>
- .layui-layer-dialog .layui-layer-content {
- text-align: center;
- }
- .layui-layer-btn {
- text-align: center;
- }
- .textadx {
- margin-top: 10px;
- font-size: 15px;
- border: solid 1px #CDCDCD;
- }
- .textadlist {
- padding: 10px;
- padding-bottom: 0;
- overflow: auto;
- }
- .textadlist li {
- text-align: center;
- width: 25%;
- float: left;
- margin-bottom: 10px;
- }
- </style>
复制代码
html代码
- <a rel="nofollow" href = "javascript:;" onclick="dshow('https://tva1.sinaimg.cn/large/006tJM44gy1fx8ptfv4cjg306i01owee.gif', '##', '标题', '广告语*广告语')"><b><font color="#FF0000">点击弹出</font></b></a>
复制代码 |