Skip to content

Instantly share code, notes, and snippets.

@robertknight
Created November 25, 2016 13:26
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 robertknight/5f3832ba3300a6b6536a237382f1db81 to your computer and use it in GitHub Desktop.
Save robertknight/5f3832ba3300a6b6536a237382f1db81 to your computer and use it in GitHub Desktop.
Firefox form submittion workaround
<html>
<head><meta charset="UTF-8"></head>
<body>
<form>
<button type="submit">
Clicking this button should submit the form and reload the page
</button>
</form>
<script>
const form = document.querySelector('form');
const deleteButton = document.querySelector('button');
// Uncomment below to work around issue
// deleteButton.type = 'button'
deleteButton.addEventListener('click', (event) => {
event.preventDefault();
deleteButton.remove();
// Does nothing in Firefox
form.submit();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment