Opening a link in a new tab using JS

Good afternoon, everyone.

There is the following code that is triggered on the click event:

var idzakaz = $(this).next('.idenzak').val();
var naklad = $(this).prev('.idnaklad').val();

window.open('?komplects='+idzakaz, '_blank');
window.open('?pechat='+naklad, '_blank');

But the following problem occurs: when you open the second link in Google Chrome, it opens not in a new tab, but in a new window. Can you tell me how to get rid of this and make both links open in new tabs?

Author: Виталина, 2014-11-20

2 answers

There was a project with a similar comment that needed to be corrected, because the client's desire is the law. The output is as follows: 1. Create an html-element, clicking on which opens the link you need in a new window. We make the element hidden. 2. Using js, we emulate clicking (submit) on this html element.

P.S. if the link is dynamic, then first use js to set the link, and then emulate the click.

 2
Author: МаринаВоин, 2014-11-21 06:08:19

Opening a link in a new window or tab is the current user's browser setting. And JS can't steer anything here.

 0
Author: aka_SKIff, 2014-11-20 19:55:14