Previously, I got a solution from here on how to open another link automatically on page load. I got this code to do that
window.setTimeout("autoClick()", 2000); // 2 seconds delay
function autoClick() {
var linkPage = document.getElementById('dynLink').href;
window.location.href = linkPage;
}
</script>
dynLink is used in the body as target="_blank" within link tag. But this is loading the desired page within the same tab. Not in a New Tab.
I want when this auto page load clicks the link with id=dynLink, the page opens in a new tab then to load in the same tab.
Looking forward to some working solution. Thanks!
Following are some of the solutions using plain HTML and JavaScript. You may use based on your requirement and share if you have any other solution.
Open Link Immediately on Page Load.
<body onload="window.open('https://www.google.com/');">
Open link in New Tab on page load.
<body onload="window.open('https://www.google.com/', '_blank');">
Refresh the same URL Using meta tags.
<meta http-equiv="refresh" content="5" />
Refresh a different URL after 5 seconds Using meta tags.
<meta http-equiv="refresh" content="5;URL='https://www.google.com/'" />
Open different URL in New Tab using meta tags.
<meta http-equiv="refresh" content="5;URL=javascript:window.open('https://www.google.com/', '_blank');" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With