Files
ClassContent/历届学生/吴欣阳/项目开发/上课项目/js案例/广告.html
2024-09-27 02:06:13 +08:00

57 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>广告</title>
<style>
body {
margin: 0;
padding: 0;
}
.ad {
width: 300px;
height: 300px;
position: fixed;
right: 0;
bottom: 0;
background: red;
}
.ad span {
width: 60px;
height: 30px;
background: #000;
color: #fff;
text-align: center;
line-height: 30px;
position: absolute;
right: 0;
top:0;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="ad">
<span>x关闭</span>
</div>
</body>
<script>
var close = document.querySelector(".ad span");
var ad = document.querySelector(".ad");
var count = 0; // 记录用户点击了几次
close.onclick = function () {
console.log("对氨基");
count+=1;
if (count == 1) {
// location.href = "https://www.baidu.com/"
open("https://www.baidu.com/")
} else {
ad.classList.add("hidden")
}
}
</script>
</html>