Forked from scottmagdalein/clickable-element.html
Last active
October 8, 2019 09:20
-
-
Save jonny-no1/f6179b0c48057e8eaebf4d666649961d to your computer and use it in GitHub Desktop.
Make the Mailchimp Subscriber popup appear on click
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This is the HTML element that, when clicked, will cause the popup to appear. --> | |
<button id="open-popup">Subscribe to our mailing list</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script> | |
<script> | |
(function MailChimpPopup(r) { | |
var loader; | |
r(["mojo/signup-forms/Loader"], function(l) { | |
loader = l; | |
}); | |
function openPopup(e) { | |
e.preventDefault(); | |
document.cookie = "MCEvilPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; | |
loader.start({"baseUrl":"mc.us11.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE"}) | |
} | |
var openBtn = document.getElementById('open-popup'); | |
if (openBtn) { | |
openBtn.addEventListener('click', openPopup); | |
} | |
}(require)); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fork loads the external script
mojo/signup-forms/Loader
immediately after page load to speed up the popup once the button is clicked.