Created
November 25, 2016 13:26
-
-
Save robertknight/5f3832ba3300a6b6536a237382f1db81 to your computer and use it in GitHub Desktop.
Firefox form submittion workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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