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

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.