2 Ways to Open URL in New Tab Using JavaScript

In HTML we use <a> tag for a hyperlink to another page. For Open URL in New Tab Using JavaScript we use <a> tag target attribute.

In HTML <a> tag’s target attribute provides a simple way to open a new tab or new window of the browser. We use _blank as a value in the target attribute in the anchor tag. Check below,

Open URL in New Tab Using JavaScript

If you want to do the with javascript to open link in a new tab, then we can use the window.open() the method as the best option in javascript.

window.open() method take two parameters,

  1. URL
  2. _blank value

Syntax of Open URL in New Tab using JavaScript

Below example is open http://www.phpcoder.tech URL in a new tab of the browser,

Also Check:

Tags: #javascript #window.open() #JavaScriptwindow.openNewTtab

Happy Coding..!

Subscribe For Latest Updates

Sign up to best of PHP Code Solutions, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

About Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
View all posts by Bikash →

2 thoughts on “2 Ways to Open URL in New Tab Using JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *