我试图实现一个mailchimp弹出我的页面,但它不起作用。为了确保它不是由于js冲突,我尝试了他们在一个简单的html页面上提供的JS代码。
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8">
<title>testpop</title>
</head>
<body>
<style>
html {
background: #3a1c71;
font-family: 'helvetica neue';
text-align: center;
font-size: 10px;
}
</style>
<!-- Here is the mailchimp js -->
<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"//mc.us17.list-manage.com","uuid":"af12c8121a0cbbd603454ea9e","lid":"4904281888"}) })</script>
</body>
</html>
然后我收到以下消息:
GET file://downloads.mailchimp.com/js/signup-forms/popup/embed.js net :: ERR_FILE_NOT_FOUND testmail.html:18未捕获的ReferenceError:require未定义
我可能不应该从源头开始 &#39; //.... 39;但就像那样&#39; http://...'
我现在没有在控制台中看到任何错误,但也没有弹出
答案 0 :(得分:1)
未捕获的参考错误不是由于弹出cookie。
您的问题是,您可能正在尝试在本地文件夹中进行测试,而不运行服务器,因此出现GET错误。 另外,将其更改为http://而不是//并不能解决问题,因为其他邪恶的弹出式内容会出错。有关相同问题的示例,请参见以下问题:Script tag is loading from file:/// instead of http://
只需在本地主机或远程服务器上运行它,就不会再次出现此错误。
我必须亲自检查一下,我认为这可能对其他新手有用。
答案 1 :(得分:0)
我找到了解决方案。 我的问题是Mailchimp使用cookie来阻止每次用户打开页面时弹出窗口。
为了克服这个设置,我不得不处理两个饼干'MCPopupClosed'和'MCPopupSubscribed'
document.cookie = "MCPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
document.cookie = "MCPopupSubscribed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
有关详细信息,请查看此问题:Launch Mailchimp evil popup onclick。 我希望它会有所帮助