【发布时间】:2019-03-28 03:47:02
【问题描述】:
我有一个作业,我需要帮助来解决它 我有一个弹出代码 HTML
/*
You'll probably want to drop a cookie so this doesn't pop up everytime. I'd recommend this plugin:
https://github.com/js-cookie/js-cookie
*/
overAge = function () {
$('#age-verify').addClass('hidden');
}
underAge = function () {
$('#age-verify').addClass('under');
}
goBack = function () {
window.history.back();
}
#age-verify {
position: fixed;
z-index: 9997;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.6);
transition: 500ms;
}
#age-verify .window {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 250px;
overflow: hidden;
padding: 40px;
margin-left: -200px;
margin-top: -125px;
background-color: #fff;
border: 6px solid #ED6A5A;
box-sizing: border-box;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
transition: 500ms;
z-index: 9998;
}
#age-verify .window span {
display: block;
text-align: center;
margin-bottom: 10px;
font-family: "Source Sans Pro", sans-serif;
}
#age-verify .window span.title {
color: #ED6A5A;
font-size: 24px;
}
#age-verify .window button {
border: 0;
margin: 0;
padding: 0;
width: 48%;
height: 60px;
color: #FFF;
font-size: 18px;
background-color: #ED6A5A;
margin-top: 20px;
font-family: "Source Sans Pro", sans-serif;
-webkit-transform: scale(1);
transform: scale(1);
transition: .2s;
}
#age-verify .window button.back {
display: block;
float: none;
margin: auto;
background-color: #fff;
color: #ED6A5A !important;
margin-top: 20px;
}
#age-verify .window button.yes {
float: left;
}
#age-verify .window button.no {
float: right;
}
#age-verify .window button:hover {
-webkit-transform: scale(1.1);
transform: scale(1.1);
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
background-color: #f29488;
}
#age-verify .window .underBox {
position: absolute;
width: 400px;
height: 250px;
padding: 40px;
top: 100%;
left: 0;
right: 0;
background-color: #ED6A5A;
transition: 500ms;
box-sizing: border-box;
}
#age-verify .window .underBox * {
color: #FFF !important;
}
#age-verify.hidden {
opacity: 0;
visibility: hidden;
}
#age-verify.hidden .window {
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
#age-verify.under .window .underBox {
top: 0%;
}
<div id="age-verify">
<div class="window"><span class="title">Are you over 18?</span> <span>To visit our website, you must be of legal drinking age.</span> <button class="yes" onclick="overAge()">Yes</button> <button class="no" onclick="underAge()">No</button>
<div class="underBox"><span class="title">Sorry!</span> <span>You need to be at least 18 to visit our website.</span> <button class="back" onclick="parent.location='https://www.google.dk/'">Go Back</button></div>
<span> </span></div>
</div>
我想添加 cookie 在加载时仅显示一次弹出窗口,并且 cookie 在一小时后过期
我尝试了很多文章,但我可能知道如何正确设置它
https://www.thepolyglotdeveloper.com/2018/02/create-email-subscription-popup-jquery/
谁能帮我解决:)
【问题讨论】:
标签: javascript