Javascript Open Link in New Window Example

31-Jan-2020

.

Admin

Hi Dev,

In this blog, I will learn you how to open link in new window using javascript. I would like to take the current page URL and open it in a new window.

I will give you simple and easy example for open link in new window using javascipt is bellow. you can see a simple example of open url in new window using window.open() in javascript.

Syntax :


window.open(URL, name, specs, replace);

Use :

window.open("https://www.nicesnippets.com/","mywindow","status=1,toolbar=1");

Example

<!DOCTYPE html>

<html>

<head>

<title>javascript open link in new window example - 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/","mywindow","status=1,toolbar=1");

}

</script>

</body>

</html>

It will help you...

#JavaScript