最近有点上课摸鱼,捣鼓的玩意,分享出来大家玩玩
- 代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>打开页面</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/layer.css">
<script src="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.js"></script>
<style>
button {
width: 30px;
background: #ff8f8f;
height: 150px;
overflow: hidden;
box-shadow: 0px 2px 5px 0 rgb(0 0 0 / 50%);
border-radius: 0px 15px 15px 0px;
text-align: center;
padding: 0 5px;
color: #fff;
display: table-cell;
vertical-align: middle;
cursor: pointer;
line-height: 20px;
border: none;
margin-top: 20%;
margin-left: -10px;
}
</style>
</head>
<body>
<button onclick="openPopup()">打开页面</button>
<script>
function openPopup() {
var title = '弹窗标题'; // 设置弹窗标题
var url = 'https://www.cenguigui.cn/player/music/'; // 设置要打开的页面地址
layer.open({
type: 2,
title: title,
shadeClose: true,
shade: 0.8,
scrollbar: false,
maxmin: true, // 开启最大化最小化按钮
area: ['80%', '90%'],
content: url,
success: function(layero, index){
var closeBtn = '<i class="fas fa-times close-btn" id="closeBtn" onclick="closePopup()">×</i>';
$(layero).find('.layui-layer-title').append(closeBtn);
}
});
}
function closePopup() {
layer.closeAll();
}
</script>
</body>
</html>