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’m with this script but I’m not getting to mount Else.
if (window.location.host == 'http://www.google.com') {
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 {
}
Remove what? you’d better use a
.match(REGEX)
than a simple comparison==
which will validate only 1 possibility.– Guilherme Lautert