
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to use JavaScript to redirect an HTML page?
You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.
It is quite simple to do a page redirect using JavaScript on the client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.
You can try to run the following code to learn how to use JavaScript to redirect an HTML page. Here, we will redirect to the homepage
Example
<html> <head> <script> <!-- function Redirect() { window.location.assign("https://www.tutorialspoint.com"); } //--> </script> </head> <body> <p>Click the following button, you will be redirected to home page.</p> <input type="button" value="Redirect Me" onclick="Redirect();" /> </body> </html>
- Related Articles
- How to use Meta Tag to redirect an HTML page?
- How to redirect from an HTML page?
- How to use an animated image in HTML page?
- How to include an external JavaScript inside an HTML page?
- How to include inline JavaScript inside an HTML page?
- How do I redirect my web page with JavaScript?
- How to make a page redirect using jQuery?
- How to use JavaScript to redirect a webpage after 5 seconds?
- How to use the tag to define style information for an HTML page?
- How to use window.location to redirect to a different URL with JavaScript?
- How to use title tag in HTML Page?
- How to use href attribute in HTML Page?
- How to use floating image in HTML page?
- How to automatically redirect a Web Page to another URL?
- How to display JavaScript variables in an HTML page without document.write?

Advertisements