未捕获的TypeError - Fancybox& jquery cookie

时间:2015-03-31 05:46:08

标签: jquery cookies fancybox shopify

我使用带有jquery cookie插件的fancybox。我的想法是在页面加载后加载fancybox并且不要显示它直到第二天。所以我已经使用了下面的代码



<script type="text/javascript">
    function openNewsletterPopup() {
      setTimeout( function() {
        $('#newsletter').fancybox({maxWidth: 600});
        $('#newsletter').trigger('click'); 
      }, 
      {% if settings.newsletter_popup_seconds != blank %}{{ settings.newsletter_popup_seconds }}{% else %}2{% endif %}*1000);
    }

    $(function() {
      var popup = $.cookie('popup');
      var cookie_enabled = {% if settings.newsletter_popup_days != blank and settings.newsletter_popup_days != "0" %}true{% else %}false{% endif %};

      if (cookie_enabled && popup == 'open') {
          return false;
      } else {
        openNewsletterPopup();
      }
      if (cookie_enabled) {
        $.cookie('popup', 'open', { expires: {{ settings.newsletter_popup_days }} });
      }
    });
  </script>
&#13;
&#13;
&#13;

但它没有用。我在控制台中看到了Uncaught Type Error。关于如何解决这个问题的任何建议?

标题代码

&#13;
&#13;
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
  <script src="//cdn.shopify.com/s/files/1/0815/3527/t/2/assets/jquery.fancybox.pack.js?2070714040394294891" type="text/javascript"></script>
  <script src="//cdn.shopify.com/s/files/1/0815/3527/t/2/assets/jquery.cookie.js?2070714040394294891" type="text/javascript"></script>
&#13;
&#13;
&#13;

由于 enter image description here

0 个答案:

没有答案