简体   繁体   中英

Pop-up ' Don't show this message again ' option

I'm not sure if this will be possible on Tumblr . The popup I have isn't a ' fancybox' . I've tried finding a solution here but I haven't had much luck . I have a pop-up box that is displayed when a visitor comes to my blog , but whenever I click the next page -- it pops up again . I do not want it popping up every time someone refreshes . I want it so it pops once every 7 days per user and it has a ' do not display message again ' option for them.

This is the script.

<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>

This is the close button

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

You will have to use cookies or sessions on your website so that you can track which users have seen pop-ups.

In this case I would probably recommend HTML5 webstorage.

HTML Local Storage

You can then store an item relating to your popup with an expiry date that you can check or set every time before showing a user a popup.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM