• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
logo

Tutsplanet

Free Technical and Blogging Resources

  • Home
  • Web Hosting
  • Programming
  • Plugins
  • Write For US
  • News
  • About Us
  • Tools
You are here: Home / Javascript / Open a URL in a new tab using JavaScript

Open a URL in a new tab using JavaScript

Feb 28, 2017 by Editorial Staff 3 Comments

Opening a URL in new tab using JavaScript, below snippet will do the trick

function OpenInNewTabWinBrowser(url) {
  var win = window.open(url, '_blank');
  win.focus();
}

You could do it this way calling a direct function, or by adding an event listener to your DOM object.

Note: JavaScript, abbreviated as JS, is a high-level, interpreted programming language. It suits for development of client side behavior. Is JavaScript is easy to learn?. Yes, you can start with JavaScript basic programs in W3school website. There are many online courses to learn javascript in learning websites like Udemy.

 


Editorial Staff

Editorial Staff at Tutsplanet is a dedicated team to write various tutorials about subjects like Programming, Technology and Operating Systems.

View all posts by Editorial Staff

Filed Under: Javascript

Reader Interactions

Comments

  1. arvind kumar says

    Jan 16, 2020 at 4:17 pm

    nice work

    Reply
  2. Vikram says

    Jun 23, 2020 at 2:50 pm

    Good work, if someone stumbles upon this and want to open link in new tab using html, check
    How to open link (a href) in new tab instead of loading url on same page?

    Reply
  3. Bappy says

    Oct 17, 2020 at 4:48 pm

    Wow! this is working for me!

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar




Quick Links

  • A Simple YouTube Video Downloader Script in PHP
  • The 50 Most Useful jQuery Plugins for Frontend Development
  • Word Set 01
  • Convert PNG to JPG Online

Subscribe

* indicates required

Share

   

Hot topics

  • A Simple YouTube Video Downloader Script in PHP 13.3k views
  • Open a URL in a new tab using JavaScript 10.7k views
  • Using Third-Party Libraries in Codeigniter 8.4k views
  • Add FTP/SFTP in Visual Studio Code 6.1k views
  • Replace “\n” with new line characters, using Notepad++ 4.8k views
  • Manually Install APK Files In Android Studio Emulator 4.7k views
  • Upload Multiple Images and Store in Database using PHP and MySQL. 4.5k views
  • How To Install And Use CKEditor In Laravel? 4.2k views
  • Simple PHP Shopping Cart 4k views
  • Spout, an awesome library for reading and writing in Excel. 3.3k views

Categories

  • Design & Development
  • Drupal
  • Facebook
  • General
  • How To
  • ios
  • Javascript
  • Linux
  • Magento
  • Marketing
  • News
  • PHP
  • Plugins
  • Programming
  • Snippets List
  • Social Media
  • Softwares
  • Themes
  • Tips
  • Wordpress
  • YouTube

Copyright © 2021 · TutsPlanet Gene Theme on Genesis Framework · Powered By BunnyCDN