[Solved] Stop Javascript function from firing onload?


The reason showmailingPopUp isn’t working with onclick is because it cannot find it. It should either be defined before in a script tag or in JavaScript binding with an event listener.

Here is a solution using JavaScript (adding an event listener to an element so the function will call correctly):

function showMailingPopUp() {
    require(
        ["mojo/signup-forms/Loader"],
        function(L) {
          L.start({"baseUrl":"mc.us4.list-manage.com","uuid":"91363270e58a57510d5d933c6","lid":"b2d7dd4078"})
        }
    );

    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("element").addEventListener("click", function(){
    showMailingPopUp();
})

jsFiddle

solved Stop Javascript function from firing onload?