Skip to content

fix: Stop Webflow JS from kidnapping the Mailchimp form #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h1 class="home__hero-title">Experimental crypto &amp; ai<br>mobile browser<br><
<div data-w-id="8318a86b-a72c-2346-4642-91eb40c29ae0" style="opacity:0" class="feature-block"><img src="images/Icon-Secure.svg" loading="lazy" alt="" class="feature-heading-icon secure">
<div class="feature-text-wrapper">
<h2>Private</h2>
<div class="feature-block-description">We dont collect your data. We don&#x27;t have annoying ads.<br>We respect your privacy.<br></div>
<div class="feature-block-description">We don't collect your data. We don't have annoying ads.<br>We respect your privacy.<br></div>
</div>
</div>
</div>
Expand All @@ -153,7 +153,7 @@ <h2 class="cta__heading h1">Sign up to stay <span class="no-wrap">up to date!</s
</div>
</div>
<div class="signup__form-wrapper w-form">
<form id="wf-form-Email-Form" name="wf-form-Email-Form" data-name="Email Form" action="https://pumabrowser.us20.list-manage.com/subscribe/post?u=5db446ce5c6b2494514683f2f&amp;amp;id=867381e98e" method="post" data-wf-page-id="5f77a6540c6ea41a27cfb71e" data-wf-element-id="3b532457-0bf9-e625-f724-d6dca96ca9a7">
<form id="mailchimp-subscribe-form" name="wf-form-Email-Form" data-name="Email Form" action="https://pumabrowser.us20.list-manage.com/subscribe/post?u=5db446ce5c6b2494514683f2f&id=867381e98e" method="post">
<div class="signup__checkbox-row">
<div class="signup__checkbox-wrapper"><label class="w-checkbox checkbox-field">
<div class="w-checkbox-input w-checkbox-input--inputType-custom checkbox"></div><input type="checkbox" id="IOS" name="IOS" data-name="IOS" style="opacity:0;position:absolute;z-index:-1"><span for="IOS" class="w-form-label">iPhone / iPad</span>
Expand All @@ -162,7 +162,9 @@ <h2 class="cta__heading h1">Sign up to stay <span class="no-wrap">up to date!</s
<div class="w-checkbox-input w-checkbox-input--inputType-custom checkbox"></div><input type="checkbox" id="ANDROID" name="ANDROID" data-name="ANDROID" style="opacity:0;position:absolute;z-index:-1"><span for="ANDROID" class="w-form-label">Android</span>
</label></div>
</div>
<div class="signup__input-wrapper"><input type="email" class="signup__input-field w-input" maxlength="256" name="email" data-name="Email" placeholder="[email protected]" id="email" required=""><input type="submit" value="Sign Up" data-wait="Please wait..." class="btn submit-btn w-button"></div>
<div class="signup__input-wrapper"><input type="email" class="signup__input-field w-input" maxlength="256" name="EMAIL" data-name="Email" placeholder="[email protected]" id="email" required=""><input type="submit" value="Sign Up" data-wait="Please wait..." class="btn submit-btn w-button"></div>
<!-- Adding Mailchimp honeypot field -->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_5db446ce5c6b2494514683f2f_867381e98e" tabindex="-1" value=""></div>
</form>
<div class="success-message w-form-done">
<div>Thank you! Your submission has been received!</div>
Expand Down Expand Up @@ -196,5 +198,32 @@ <h2 class="cta__heading h1">Sign up to stay <span class="no-wrap">up to date!</s
</main>
<script src="https://d3e54v103j8qbb.cloudfront.net/js/jquery-3.5.1.min.dc5e7f18c8.js?site=5f77a654cd59b4738a0160a0" type="text/javascript" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="js/webflow.js" type="text/javascript"></script>
<script>
// Force standard form submission for Mailchimp form
(function() {
var form = document.getElementById('mailchimp-subscribe-form');
if (form) {
form.addEventListener('submit', function(event) {
// Stop Webflow's JS (and any other listeners) from hijacking the submit
event.stopImmediatePropagation();
event.preventDefault(); // Extra safety
// Allow the browser's default submit to happen after a tiny delay
var currentForm = event.target;
setTimeout(function() {
// Check if the native submit method exists before calling
if (typeof currentForm.submit === 'function' && !currentForm.submit.toString().includes('[native code]')) {
// If submit has been overridden by JS (common in libraries), find the prototype
HTMLFormElement.prototype.submit.call(currentForm);
} else if (typeof currentForm.submit === 'function'){
// Otherwise, call the native submit directly
currentForm.submit();
} else {
console.error('Could not trigger native form submission.');
}
}, 10); // 10ms delay
}, true); // Use capture phase to run before Webflow's listener
}
})();
</script>
</body>
</html>