2016-06-22 133 views
1

我不确定这是否可能在Tumblr上。我拥有的弹出窗口不是'fancybox'。我试过在这里找到解决方案,但我没有太多的运气。当访问者访问我的博客时显示一个弹出框,但每当我点击下一页时,它都会弹出。每次有人刷新时,我都不希望它弹出。我需要它,因此它每7天每个用户弹出一次,并且它有一个“不再显示消息”选项。弹出“不再显示此消息”选项

这是脚本。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js"> </script> 

<script> 
$(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').show(1000); 
$('#mask').fadeTo("slow",0.5); 

//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).show(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(); 
}); 




}); 

</script> 

这是关闭按钮

<a href="#" title="close" class="close"><div class="rotating" style="margin- left:395px; margin-top:-25px; position:absolute;"><big>✦</big> </div></a><br><br> 

回答

3

你将不得不使用cookie或会话在您的网站,这样你可以跟踪哪些用户看到弹出窗口。

在这种情况下,我可能会推荐HTML5 webstorage。

HTML Local Storage

然后,您可以存储与您的弹出与您可以显示用户的弹出之前检查或设置每次到期日期的项目。

希望这会有所帮助。

+0

我觉得我得到它的工作!谢谢 ! – Brick