javascript Open Link in New Tab on Click

Admin   HTML5 - CSS   287  2021-03-13 03:00:05

Hi Guys,

In this blog, I will teach you how to oprn link in new tab using on click in javascript. Open url in new tab then you can use this example.

You will see example of onclick open link in new tab in javascipt. I am use window.open() to open link in new tab using javascript.

Let's see example and you can use anyone as you need.

Example

 

<!DOCTYPE html>

<html>

<head>

<title>javascript open link in new tab on click - </title>

</head>

<body>

<h1>NiceSnippets.com</h1>

<button onclick="getLink();">Click me</button>

<script type="text/javascript">

function getLink() {

window.open("/");

}

</script>

</body>

</html>

It will help you...