2016-06-22 125 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