Skip to content

Open a link without clicking on it using HTML | Example Code

  • by

Use window.open with URL inside the auto trigger script to open a new link without clacking in HTML webpage.

Open a link without clicking on it example

Alone HTML is not possible to open an link in HTML. You can pass the function into onload attribute of body. Where function will trigger a URL and open new tab .

<html>

<script>
	function openInNewTab(url) {
		var win = window.open(url, '_blank');
		win.focus();
	}
</script>

<body onload=openInNewTab("https://tutorial.eyehunts.com/")>

</body>
</html>

Output:

Open a link without clicking on it using HTML

Do comment if you have any doubts and suggestion on this HMTL topic.

Note: The All HTML Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading