For example,
<script> let redirectPage = () => { window.location = "https://www.encodedna.com/"; // OR window.location.href = "https://www.encodedna.com/"; } </script>
If you want, you can delay the redirect by few seconds. See this article.
Redirect Page but Open page in a New Tab
The window.location or window.location.href will open the redirected page on the current window. Your users will have to click the browser's back button to navigate back to the original page. So, here's an altenative. You can use window.open() method to open the redirected page in a new tab or window.
<script>
let redirectPage = () => {
window.open("https://www.encodedna.com/", "_blank");
}
</script>
Note: You can learn more about window.open() method and its parameters here.
Redirect to Another Page using a Parameter
You can redirect to another page using a parameter in JavaScript. The URL of a webpage can have parameters. So, here’s how you can do this.
<script> let redirectPage = () => { window.open("https://www.encodedna.com/?pg=2", "_blank"); } </script>
Note: If you want, you can add multiple parameters to the redirect URL. For example,
https://www yourwebsite com/content/ocncontent?userid=43&contentid=9