Posted injQuery / JavaScript

How to Open Webpage Links in a New Tab in jquery?

Today, We want to share with you jquery open link in new tab.In this post we will show you how to open a referenced resource of a link in a new tab in jQuery Example., hear for first of all Opening of a URL in a new tab or window depends on the browser and the user’s browser preferences. we will give you demo and example for implement.In this post, we will learn about jquery – Simple open url in new window jquery with an example.

How to open a URL in a new tab (and not a new window) using jQuery?

There are some times when you pay want to force links URL to open in a new window. It could be to open read and write permission, adverts or external links. IMP: that some believe that you should never force a href link to open in a new window or new tab as that decision should be left to the visitors.

using jQuery Example

$(document).on('click', 'a', function(e){ 
    e.preventDefault(); 
    var url = $(this).attr('href'); 
    window.open(url, '_blank');
});

PHP Open Hyperlinks in New tab window
PHP Open Hyperlinks in New tab window

using JavaScript(Use window.open():)

var blog = window.open('https://www.yourdomainname.com/', '_blank');
if (blog) {
    //Browser detect has allowed it to be opened
    blog.focus();
} else {
    //Browser has blocked it
    alert('Please allow popups for this Blogspot');
}

Create hidden anchor tag

With jQuery library, you can create new anchor tag like:

$(document).ready(function() {
  $("#findproducts").click(function() {
    $("").prop({
      target: "_blank",
      href: "https://www.yourdomainname.com"
    })[0].click();
  });
});

How to Open URL in New Tab using Jquery?

HTML a href target attribute supports simply as well as tiny way to open the linked URL in the new browser window or tab.

Example 1: jQuery attribute equals selectors




    Jquery Open Link in New Tab on Click Example - infinityknow.com
    







This will instruct the browser Like as a Mozila, Chrome or more to leave the current Live active page as is and open the link in a new tab/window.

Example 2: Target _blank alternative




    Jquery Open Link in New Tab on Click Example - infinityknow.com



	Click Me


You need to use the _blank value in the target attribute to open the linked URL in a new tab or window.

Visit pakainfo

using a Specify a class

HTML Code

Read and Write Permmitions

jquery code

$(document).ready(function(){

  $('a.codelp').click(function(){
    window.open(this.href);
    return false;
  });

});

The bellow JavaScript simple source code will open https://www.pakainfo.com in a new browser tab or window.

window.open('https://www.pakainfo.com', '_blank');

I hope you get an idea about jquery open link in new window.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype