嗨,我在这个链接http://my-cravings.com/cravings-group-events-and-services-inquiry上有这个弹出模式,我希望弹出窗口每个浏览器会话只显示一次,有没有办法实现这个??谢谢..请帮忙。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="boxes">
<div id="dialog" class="window">
<a class="modal" href="index.php?option=com_rsform&formId=22&tmpl=component">Please click this to proceed</a>
</div>
<div id="mask"></div>
</div>
&#13;
$(document).ready(function() {
var id = '#dialog';
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(500);
$('#mask').fadeTo("slow",0.9);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
#mask {
position: absolute;
left: 0;
top: 0;
z-index: 9000;
background-color: #000;
display: none;
}
#boxes .window {
position: absolute;
left: 0;
top: 0;
width: 440px;
height: auto;
display: none;
z-index: 9999;
padding: 10px;
border-radius: 5px;
text-align: center;
}
#boxes #dialog {
height: auto;
padding: 5px;
background-color: #ffffff;
font-size: 12pt;
}
#popupfoot {
font-size: 16pt;
position: absolute;
bottom: 0px;
width: 250px;
left: 250px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
答案 0 :(得分:1)
尝试使用javascript sessionStorage。在显示弹出窗口之前将其用于您的状态
答案 1 :(得分:0)
就像wehpogi所说,你可以使用sessionStorage
来存储一个标志,表明你已经显示了弹出窗口。如果用户的浏览器没有sessionStorage
支持,您可以回退使用Cookie。