How to Redirect to a Page Using JavaScript
JavaScript provides a simple way to redirect users to a different page from the current page. To achieve this, you can utilize the window.location property.
Redirect with JavaScript
To redirect to another page, follow these steps:
1. Set the window.location property to the target URL:
window.location = "http://www.yoururl.com";
This line of code will immediately redirect the user to the specified URL.
Example:
window.location.href = "https://example.com"; // Redirect to "example.com" window.location.assign("https://example.org"); // Also redirect to "example.org" window.location.replace("https://example.net"); // Replaces the current page with "example.net"
Note:
The above is the detailed content of How to Redirect to a Page Using JavaScript?. For more information, please follow other related articles on the PHP Chinese website!