Below code takes an input url from the user and the url is stored in a variable through getElementById() and window.location takes the page to that url.
At first this will be the output, and then if the link like (https://www.geeksforgeeks.org/) is put inside the box, it will redirect to the home page of the GeeksforGeeks and will be shown like below.
Steps for executing above codes:
- Save these files with .html extension as file_name.html
- Then open the files in a browser, it will get redirect to the GeeksforGeeks homepage.
- How to redirect to another webpage in HTML?
- How to use Meta Tag to redirect an HTML page?
- How to redirect a page to another page in HTML ?
- ES6 | Page Redirect
- Post/Redirect/Get (PRG) Design Pattern
- Express.js res.redirect() Function
- ASP Redirect Method
- How to redirect to a particular section of a page using HTML or jQuery?
- How to force redirect to a particular route in angular?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.