One-time FancyBox popup like on Digg.com

筅森魡賤 提交于 2019-12-06 14:56:08

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/11420201/one-time-fancybox-popup-like-on-digg-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!