Created
March 16, 2018 22:20
-
-
Save rheid/f8547a9ac22cc0dc4eabc9e0267f9b71 to your computer and use it in GitHub Desktop.
CHANGE DEFAULT FORM BUTTON REDIRECT – THE SIMPLE WAY
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
function changeRedirect(options) { | |
for (var i = 0, buttons = document.querySelectorAll(options.selector); i < buttons.length; i++) { | |
var newOnClick = function(originalOnClick) { | |
return function(){ | |
Nav.navigate = STSNavigate = function() { | |
window.location = options.redirectTo | |
} | |
originalOnClick() | |
} | |
} | |
buttons[i].onclick = newOnClick(buttons[i].onclick) | |
} | |
} | |
document.addEventListener("DOMContentLoaded", function(event) { | |
changeRedirect({ | |
selector: "input[value=Save]", | |
redirectTo: "https://google.com" | |
}) | |
changeRedirect({ | |
selector: "input[value=Cancel]", | |
redirectTo: "https://bing.com" | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment