window.open with target “_blank” in Chrome

爱⌒轻易说出口 提交于 2019-11-26 23:20:16

问题


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?


回答1:


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




回答2:


"_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.




回答3:


window.open(skey, "_blank", "toolbar=1, scrollbars=1, resizable=1, width=" + 1015 + ", height=" + 800);



回答4:


You can't do it because you can't have control on the manner Chrome opens its windows




回答5:


As Dennis says, you can't control how the browser chooses to handle target=_blank.

If you're wondering about the inconsistent behavior, probably it's pop-up blocking. Many browsers will forbid new windows from being opened apropos of nothing, but will allow new windows to be spawned as the eventual result of a mouse-click event.



来源:https://stackoverflow.com/questions/11035937/window-open-with-target-blank-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!