2 Ways to Open URL in New Tab Using JavaScript

By | June 3, 2020

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..!

Share and Enjoy !

0 0

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.

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

  1. Pingback: CSS Background Image Text Effect - PHPCODER.TECH

  2. Pingback: JavaScript Append HTML to Body - PHPCODER.TECH

Leave a Reply

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