2015-04-17 223 views
6

我已经关注this tutorial实施弹出式电子邮件时事通讯注册,以添加到我的Shopify主题,该主题使用了fancybox.js & cookie.js。除非输入电子邮件地址,否则一切正常。&即使打开了一个附加选项卡以完成Mailchimp注册过程,在原始商店选项卡上,点击'注册',电子邮件弹出窗口保持打开状态,就像没有任何更改。点击按钮淡出弹出窗口?

我想知道是否有一种方法可以调整代码,以便点击'注册'时,新标签会正常打开,但电子邮件弹出消失,所以当用户返回商店时,流行消失了。我不擅长JS,所以任何帮助将非常感激!

我当前的代码:

theme.liquid -

液体HTML:

{% if settings.popup_newsletter_enable %} 
    <div id="email-popup" style="display: none;" > 
    {% include 'popup-newsletter-form' %} 
    </div> 

    <a href="#email-popup" id="trigger"></a> 
{% endif %} 

JS:

{{ 'jquery.fancybox.js' | asset_url | script_tag }} 

<script type="text/javascript"> 
    (function($) { 
    // set a variable for the cookie check 
    var check_cookie = $.cookie('popup_box'); 

    // check whether the cookie is already set for this visitor 
    if(check_cookie != 'active'){ 
     // if the cookie does not exist do the following: 

     // (1) set the cookie so it's there for future visits (including an expiration time in days) 
     $.cookie('popup_box', 'active', { 
     expires: 3, 
     path: '/' 
     }); 

     // (2) trigger the fancybox pop up, specifying that it's inline 
     $('#trigger').fancybox({ 
     type: 'inline', 
     }); 
     setTimeout(function() { 
     $('#trigger').eq(0).trigger('click'); // make the click event happen on load 
     }, 5000); 
    } 
    })(jQuery); // this is a noconflict wrapper for WP 
</script> 

弹出快讯 - form.liquid(片段包括) :

液体HTML:

<!-- Mailchimp Form Integration --> 
{% if settings.newsletter_form_action != blank %} 
    {% assign form_action = settings.newsletter_form_action %} 
{% else %} 
    {% assign form_action = '#' %} 
{% endif %} 
<form action="{{ form_action }}" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank" class="input-group"> 
    <input type="email" value="{% if customer %}{{ customer.email }}{% endif %}" placeholder="{{ 'general.newsletter_form.newsletter_email' | t }}" name="EMAIL" id="mail" class="input-group-field" aria-label="{{ 'general.newsletter_form.newsletter_email' | t }}" autocorrect="off" autocapitalize="off"> 
    <span class="input-group-btn"> 
    <input type="submit" class="btn" name="subscribe" id="subscribe" value="{{ 'general.newsletter_form.submit' | t }}"> 
    </span> 
</form> 

回答

1
$('#pro_image').click(function(){ 
     $("#pro_image").fancybox({ 
      closeSpeed : 250, 
      closeEasing : 'swing', 
      closeOpacity : true, 
      closeMethod : 'zoomOut', 
    }); 
    }) 

;

试试这个。

+0

是的,我只是给你看看密码的代码。 – Tanmoy

+0

对不起我的错误。 – Tanmoy

+0

我已编辑代码看看,它可能会帮助你。 – Tanmoy

0

通常他们把js放在标题里面,也可以放在标签内的任何地方,但是他们会说最好放在代码的底部(内部),让所有的代码都可以通过浏览器和js执行。