Skip to content

Instantly share code, notes, and snippets.

@Jamedjo
Created June 26, 2015 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jamedjo/c07433cc08e473be7e2a to your computer and use it in GitHub Desktop.
Save Jamedjo/c07433cc08e473be7e2a to your computer and use it in GitHub Desktop.
Strikingly enter submit fix
function addEvent(element, eventName, fn) {
if (element.addEventListener)
element.addEventListener(eventName, fn, false);
else if (element.attachEvent)
element.attachEvent('on' + eventName, fn);
}
var wasEnterPressed = function(e){
return e.which == 13 || e.keyCode == 13;
};
var onFormSubmit = function(){
var email_submit = document.querySelectorAll('.signup-form input.submit-button[type="button"]')[0];
email_submit.click();
};
var onEmailKeyPress = function(e){
if(wasEnterPressed(e)) {
onFormSubmit();
}
};
var onLoadOrNow = function(f){
if (document.readyState === 'complete'){
f();
} else {
addEvent(window, 'load', f);
}
};
onLoadOrNow(function(){
var email_input = document.querySelectorAll('.signup-form input[name="collected_email[email]"]')[0];
addEvent(email_input, 'keypress', onEmailKeyPress);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment