Remove action in window.location

0

I am creating a comparison that will do the following, if the address is www.google.com will perform the function otherwise it will remove. I am with this script but I am not able to mount the else.

if (window.location.host == 'http://www.google.com.br') {
    var optinBtn = document.querySelector('#newsletterButtonOK'),
        clickFnc = document.querySelector('#newsletterButtonOK').onclick;

    window.optinHandler = function () {
        Bat.cookie.set('allin-optin', document.querySelector('#newsletterClientEmail').value, 60);
        clickFnc();
    };

    optinBtn.setAttribute('onclick', 'window.optinHandler()');
} 
else {

}
    
asked by anonymous 06.04.2016 / 15:01

1 answer

0

You can use a method of "History"

window.history.pushState(window.location.host, "Titulo", "/NovaUrl");

This method will replace the URL.

Check out the documentation .

    
06.04.2016 / 18:35