我在下面有这个项目来测试我的同意覆盖页面。
警告页面工作正常,但不保存您的选项。因此,如果您进入网站,通过它导航然后再返回主页,您将再次看到同意覆盖。
有没有办法使用cookies保存选项?
Project( SFW )
使用同意覆盖页面代码的代码段
提前谢谢!
function openDialog() {
document.documentElement.style.overflow = "hidden";
}
function closeDialog() {
document.getElementById("warning").classList.remove("show")
document.getElementById("warning").classList.add("hide");
}
openDialog();

body,
html {
overflow: hidden;
height: 100%;
margin: 0;
}
.consent-overlay {
position: fixed;
z-index: 999;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.consent {
background: #000000;
height: 100%;
background-position: center;
background-size: cover;
position: relative;
color: #f8f8f8;
font-family: inherit;
}
.consent-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.consent-content h1 {
text-transform: uppercase;
font-size: 1.4rem;
font-weight: 300;
letter-spacing: .1rem;
text-indent: .1rem;
margin-top: 40px;
}
.button {
text-decoration: none;
display: inline-block;
font-size: 35px;
cursor: pointer;
padding: 30px 30px;
margin: 0px auto;
letter-spacing: 1.2rem;
}

<link href='https://fonts.googleapis.com/css?family=Raleway:100,200,300,400,500,600,700,800,900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<div id="warning" class="consent-overlay show">
<div class="consent">
<div class="consent-content">
<img src="https://i.imgur.com/OtN0ZEJ.png" width="200" height="200">
<h1>Este website exibe contéudo explícito!</h1>
<div class="button">
<button type="button" class="btn btn-outline-success" onclick="closeDialog("warning")">Tenho mais de 18 anos</button>
<button type="button" class="btn btn-outline-danger" onclick="location.href='https://www.webnode.com.br';">Tenho menos de 18 anos</button>
</div>
</div>
</div>
</div>
&#13;