agassi0430
agassi0430

Reputation: 1195

Open link in new tab does not work in IE10

I am using window.open in jquery to open a link in a new tab. Works fine for me in chrome/safari/firefox, but it does not work in IE10.

$('.div').click(function() {
    $(this).target = "_blank";
    window.open('http://url/15M');
    return false;
});

How can I fix this?

Upvotes: 2

Views: 8434

Answers (2)

Sampson
Sampson

Reputation: 268344

The browser itself will decide when it's appropriate to open a new tab versus a new window, though you can influence its decision via browser settings. That being said, there are often times certain things we can do to encourage one way over the other. In this particular instance, I was able to get IE10 to open a window by passing along width and height values:

$("button").on("click", function () {
    window.open("http://msdn.microsoft.com", "popup", "width=640,height=480");
});

Keep in mind that you ultimately have no control over whether something opens in a new tab, or a new window. That is entirely up to the user's machine; so don't bake any user experience dependencies into this assumption.

Upvotes: 1

Marek Lewandowski
Marek Lewandowski

Reputation: 3401

Try following:

$('.div').click(function() {
    window.open('http://url/15M', '_blank');
    return false;
});

Upvotes: 1

Related Questions