js制作首次点击页面出现弹窗

使用js实现首次进入页面时出发弹窗,之后刷新页面也不会出现

除非关闭网页重新打开,否则不会弹出第二次

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}

.xxx {
width: 100%;
height: 31.25rem;
/* display: flex; */

}

.xxx input {
width: 20px;
height: 20px;
float: right;
margin-top: 2px;
position: sticky;

}

.xxx p {
text-align: center;
margin-top: 50px;
display: inline-block;
}

/* .xxtx {

} */

.x1 {
width: 100%;
height: 200px;
background-color: #333333;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
}

.x1 img {
width: 60px;
height: 60px;
margin-left: 20px;
margin-top: 20px;
border-radius: 38px;
}

.xx {
width: 75%;
height: 300px;
background-color: antiquewhite;
margin-top: 6.25rem;
border-radius: 20px;
margin-left: 12.5%;
/* position: fixed; */
position: absolute;
display: flex;
}

.banner {
width: 90%;
height: 150px;
margin-left: 5%;
margin-top: -95px;
border-radius: 8px;
}

.list {
width: 100%;
height: 150px;
border-radius: 8px;
overflow: hidden;
}

.and {
width: 300%;
height: 150px;
border-radius: 8px;
}

.and img {
width: 33.33%;
/* height: 150px; */
border-radius: 8px;
float: left;
object-fit: inherit;
}
</style>
</head>
<body>
<!--html 开平弹窗开始制作 -->
<div class="xx">
<div class="xxx">
<input type="image" src="img/专属商品.png" onclick="fn()">
<p>回馈活动,精彩活动,马上上线,敬请期待吧</p>
</div>
<div class="x1">
<img src="img/jay.jpg">
</div>

<script type="text/javascript">
let xx = document.getElementsByClassName("xx");
let bun = sessionStorage.getItem('tuu');
if (bun == '1') {
xx[0].style.display = 'none';
}
function fn() {
xx[0].style.display = 'none';

sessionStorage.setItem('tuu', '1');
}
</script>
</body>
</html>

因为是自己练习时写的,所以样式写的非常草率,若需要可以自己改一下。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值