[代码] 点击超链接时弹出层(可用于弹出二维码或图片广告等)

[复制链接]
本站网友  发表于 2020-8-27 23:32 |阅读模式

(jQuery弹出层

点击文字等超链接时弹出层(可用于弹出二维码或图片广告等)
代码原作者网站可运行演示
https://www.layui.com/doc/modules/layer.html

下面用于点击文字超链接弹出二维码的代码
首先需要在网站页面加入两个公共js ↓
  1. <script src = "https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  2. <script src = "https://cdnjs.cloudflare.com/ajax/libs/layer/3.1.1/layer.js"></script>
复制代码

js代码;
  1. <script>
  2.     var myjq = jQuery.noConflict();
  3.    function dshow(qrcode, url, title, comment) {
  4.        layer.open({
  5.            type: 0,
  6.             title: title,
  7.            content: '<img src = "'+qrcode+'" width = "200px" height = "200px"/><br /><b style = "color: #F00;">'+comment+'</b>',
  8.            area:['320px', '360px'],
  9.            btn: '进入链接',
  10.            yes: function(index) {
  11.                layer.close(index);
  12.                location.href = url;
  13.            },
  14.        });
  15.    }
  16. </script>
复制代码

css样式代码;
  1. <style>
  2.    .layui-layer-dialog .layui-layer-content {
  3.       text-align: center;
  4.    }
  5.    .layui-layer-btn {
  6.       text-align: center;
  7.    }
  8.     .textadx {
  9.         margin-top: 10px;
  10. font-size: 15px;
  11.         border: solid 1px #CDCDCD;
  12.     }
  13.     .textadlist {
  14.         padding: 10px;
  15.         padding-bottom: 0;
  16.         overflow: auto;
  17.     }
  18.     .textadlist li {
  19.         text-align: center;
  20.         width: 25%;
  21.         float: left;
  22.         margin-bottom: 10px;
  23.     }
  24. </style>
复制代码

html代码
  1. <a rel="nofollow" href = "javascript:;" onclick="dshow('https://tva1.sinaimg.cn/large/006tJM44gy1fx8ptfv4cjg306i01owee.gif', '##', '标题', '广告语*广告语')"><b><font color="#FF0000">点击弹出</font></b></a>
复制代码

QQ|删帖注销|手机版|资源圈

GMT+8, 2024-5-4 05:25

Powered by Discuz!

© 20022-2026 Comsenz Inc.

快速回复 返回顶部 返回列表