Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.open with target "_blank" in Chrome

I have a small javascript function which opens an url in a new tab:

function RedirectToPage(status) {
   var url = 'ObjectEditor.aspx?Status=' + status;
   window.open(url , '_blank');
}

This always works when called client-side by clicking a button, even in chrome. But in Chrome it won't work when it's called from server-side(!) by using

ScriptManager.RegisterClientScriptBlock()

In Firefox and IE it opens the url in a new tab, but chrome opens the url in a new window. What could be a workaround to force Chrome to open it in a new tab?

like image 631
Jan-Patrick Ahnen Avatar asked Jun 14 '12 15:06

Jan-Patrick Ahnen


People also ask

What is _blank in window open?

a target=”_blank” Open in New Browser Tab (or Window) The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window.

Why is target _blank?

target="_blank" is a special keyword that will open links in a new tab every time. target="blank" will open the first-clicked link in a new tab, but any future links that share target="blank" will open in that same newly-opened tab.

Is Target _blank deprecated?

It looks like target="_blank" is still alright. It is listed as a browsing context keyword in the latest HTML5 draft.

How do you add a target _blank to a URL?

Conclusion. You can use the target="_blank" attribute if you want your users to click on a link that opens up a new browser tab. The target="_blank" attribute is used inside the opening anchor tag like this.


2 Answers

It's a setting in chrome. You can't control how the browser interprets the target _blank.

like image 54
Dennis Traub Avatar answered Oct 06 '22 16:10

Dennis Traub


"_blank" is not guaranteed to be a new tab or window. It's implemented differently per-browser.

You can, however, put anything into target. I usually just say "_tab", and every browser I know of just opens it in a new tab.

Be aware that it means it's a named target, so if you try to open 2 URLs, they will use the same tab.

like image 23
Jordan Avatar answered Oct 06 '22 15:10

Jordan