Created
September 3, 2019 23:22
-
-
Save masautt/e6fc62dc2712f75ca054f582df407720 to your computer and use it in GitHub Desktop.
How to redirect to another webpage in JavaScript?
This file contains hidden or 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
| // Through the console? | |
| window.location.replace("https://google.com"); | |
| // Put it on a button? | |
| document.getElementById("myBtn").addEventListener("click", () => { | |
| window.location.href = "https://google.com"; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment