One-time FancyBox popup like on Digg.com

2019-04-16 20:54发布

How can I go about actioning a FancyBox popup that notifies new users of a quick sign-up button (or whatever is chosen) like on Digg.com ... and as with Digg just one time. I really have no experience with cookies but already have FancyBox running in other parts of the website, so the basis is already there. I require the popup to appear on page load. Any pointers very happily received!

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-16 21:30

You can find a code example here https://stackoverflow.com/a/8305703/1055987 including the link to the jQuery Cookie plugin.

查看更多
闹够了就滚
3楼-- · 2019-04-16 21:33

My eventual solution uses the Reveal Modal plugin (click here) to trigger inline to 'fire' on page load using the modified following code for the popup to be displayed only once every three days. Remember also to load jquery.cookie.js and then add the following code:

<script type="text/javascript">
jQuery(document).ready(function(){
   if (jQuery.cookie('test_status') != '1') {
     jQuery('#myModal').reveal()
        jQuery('#myModal').trigger('click');
        jQuery.cookie('test_status', '1', { expires: 3}); }
   });
</script>

Using something other than FancyBox was the answer to the original question as it seemed there was a conflict somewhere, so using Reveal made the two functions completely separate. I should also note that the .css contents from the Reveal download were added to our site's stylesheet.

Hopefully that will help someone else out.

查看更多
登录 后发表回答