Answer the question
In order to leave comments, you need to log in
How to remember window in cookie?
Every time the page is refreshed, how to remember in a cookie?
<style>
#parent_popup {
background-color: rgba(0, 0, 0, 0.8);
display: none;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#popup {
background: #000;
max-width: 500px; /*Ширина окна*/
margin: 10% auto;
padding: 5px 20px 13px 20px;
border: 10px solid #00a65a;
position: relative;
/*--CSS3 CSS3 Тени для Блока--*/
-webkit-box-shadow: 0px 0px 20px #000;
-moz-box-shadow: 0px 0px 20px #000;
box-shadow: 0px 0px 20px #000;
/*--CSS3 Закругленные углы--*/
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#popup h1{
font:28px Arial;
font-weight: bold;
text-align: center;
color: #008000;
text-shadow: 0 1px 3px rgba(0,0,0,.3);
}
#popup h2{
font:24px Arial;
color: #008000;
text-align: left;
text-shadow: 0 1px 3px rgba(0,0,0,.3);
}
/* кнопка закрытия */
.close {
background-color: rgba(0, 0, 0, 0.8);
border: 2px solid #ccc;
height: 24px;
line-height: 24px;
position: absolute;
right: -24px;
cursor: pointer;
font-weight: bold;
text-align: center;
text-decoration: none;
color: rgba(255, 255, 255, 0.9);
font-size: 14px;
text-shadow: 0 -1px rgba(0, 0, 0, 0.9);
top: -24px;
width: 24px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-ms-border-radius: 15px;
-o-border-radius: 15px;
border-radius: 15px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover {
background-color: rgba(0, 122, 200, 0.8);
}
</style>
<div id="parent_popup">
<div id="popup">
<h1>Вам есть 18?</h1>
<h2>Если вам нету 18 покиньте эту страницу!</h2>
Данная страница предназначена только для лиц <strong>18+</strong>
<p>Так как данное сообщество тематики старше <strong>18-ти</strong> лет.<p>
<center>
<input type="button" class="btn btn-warning start" value="Мне есть 18" onclick="document.getElementById('parent_popup').style.display='none';">
<input type="button" class="btn btn-warning start" value="Мне нету 18" onclick="exit()">
</center>
</div>
</div>
<script type="text/javascript">
if (document.cookie.indexOf('_visited=1') == -1) {
/*код с всплывающим окном*/
document.cookie = '_visited=1; path=/';
}
var delay_popup = 1000;
setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup);
function exit(){
var thisWindow = window.open("index.php",'_self');
var exit = confirm("Хотите закрыть страницу?");
if(exit){
thisWindow.close();
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Might be worth setting a cookie expiration date
var date = new Date();
date.setDate(date.getDate()+30); // месяц
document.cookie = "_visited=1; path=/; expires=" + date.toUTCString();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question