How to Open Link in New Tab on Click in javascript ?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this blog, I will show you how to open the link in new tab by using on click in javascript. IF you want to open url in the new tab then you can follow this example.

Here you will see the full example of onclick open link in the new tab in javascipt. So now here i am use window.open() to open the link in new tab by using javascript.

So Let’s start and see example and we can use anyone of this as you need.

Example

<!DOCTYPE html>
<html>
<head>
    <title>javascript open link in new tab on click - codingspoint.com</title>
</head>
<body>
    
    <h1>codingspoint.com</h1>

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

    <script type="text/javascript">
        function getLink() {
            window.open("https://www.codingspoint.com/");
        }
    </script>
</body>
</html>

Read Also : Laravel 8 Mobile Number Verification Tutorial

Thank you read.Hope it will help you. Also follow onĀ facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →