我正在尝试添加一个菜单项,单击该菜单项将打开Mailchimp弹出窗体。虽然我熟悉VBA和Access开发,但我对Web/WordPress开发的知识有限。
以下是我迄今为止根据在线研究尝试的代码片段:
1) 我在几个不同的网站上找到了这个。问题是,似乎没有任何方法可以让它从菜单项启动。
<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script type="text/javascript">
function showPopup() {
window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us20.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE","uniqueMethods":true}) });
//unsetting the cookie
document.cookie = "MCPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "MCPopupSubscribed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
}
document.getElementById("show-popup").onclick = function() { showPopup(); }
</script>
2) 这是我第二次尝试。<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("menu-item-364").on("click",function showPopup() {
window.dojoRequire(["mojo/signup-forms/Loader"], function(L) {
e.preventDefault();
L.start({"baseUrl":"mc.us20.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE","uniqueMethods":true}) });
////unsetting the cookie
document.cookie = "MCPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "MCPopupSubscribed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
});
});
document.getElementById("show-popup").onclick = function() { showPopup(); }
我还阅读了另一篇帖子,其中有人建议使用addEventListener onhashchange事件来启动该功能,a)我无法让它工作,b)我担心它会在标签更改的任何时候启动,如果我将来使用锚导航到网站的其他区域,会导致问题。我错过了什么?