试图让 Mailchimp 的弹出表单在我的 Jekyll Powered Github 页面上单击即可工作。
我遵循的步骤:
我在我的网站上创建了一个链接来触发弹出窗口:
<a href="#" id="open-popup" onclick ="showMailingPopUp(); return false;">Join Newsletter</a>
以上内容位于我的导航栏 ( masthead.html
)的 HTML 中。
然后,我为 mailchimp 弹出代码 ( newsletter.html
)创建了一个 HTML 。是的,uuid 和盖子被我自己的哈希值取代了
<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script>
function showMailingPopUp() {
require(
["mojo/signup-forms/Loader"],
function(L) {
L.start({"baseUrl":"mc.us12.list-manage.com","uuid":"myuuid","lid":"mylid"})
}
);
document.cookie = "MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
document.cookie = "MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
}
document.getElementById("open-popup").onclick = function() {showMailingPopUp()};
</script>
调用之前newsletter.html
添加了一个包含:masthead.html
</body>
{% include newsletter.html %}
以上都没有运气:-(
有关如何修复它的任何指示?
javascript 加载顺序有问题。Jquery 在您的时事通讯代码之后加载,这就是产生错误的原因。
{% include newsletter.html %}
在_includes/masthead.html 中删除{% include newsletter.html %}
在布局/ default.html中,刚刚闭幕前</body>
它有效!
奖励:您也可以删除多余的<body>
和</body>
标签_includes / masthead.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句