javascript Open Link in New Tab on Click

JavaScript

Nicesnippets

591

31-01-2020


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 - nicesnippets.com</title>

</head>

<body>

<h1>NiceSnippets.com</h1>

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

<script type="text/javascript">

function getLink() {

window.open("https://www.nicesnippets.com/");

}

</script>

</body>

</html>

It will help you...


Recommended Posts