简体   繁体   English

ScriptManager在新选项卡中打开链接

[英]ScriptManager to open link in new tab

In bleow code Page is opening in a new window. 在停用代码中, Page在新窗口中打开。 My requirement is to open it in a new tab. 我的要求是在新标签页中打开它。

  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup",
      "window.open('" + strFilePath + "','_blank')", true);

You can't open a new tab because that's up to the browser to decide. 您无法打开新标签,因为这取决于浏览器。 The user can configure his browser to open a new window on a separate tab. 用户可以配置其浏览器以在单独的选项卡上打开新窗口。 In the latter case, your code will work. 在后一种情况下,您的代码将起作用。

If you want the user to have a windows opened in a new tab, you can only display a link and have the user, right click it, etc. 如果希望用户在新选项卡中打开窗口,则只能显示一个链接并让该用户右键单击它,依此类推。
Note, that clicking a link can still cause a postback on the current page. 请注意,单击链接仍会在当前页面上造成回发。
You'll just use a redirection on your postback. 您只需在回发中使用重定向。

http://msdn.microsoft.com/en-us/library/ms153108.aspx http://msdn.microsoft.com/en-us/library/ms153108.aspx

Never waste your effort controlling client environment, I have done it many times, may be disabling right click or opening in new window, and finally had to live up with client settings for my code or hack to work the way I expected it to. 从来没有浪费您的精力来控制客户端环境,我已经做了很多次,可能禁用了右键单击或在新窗口中打开,最后不得不忍受客户端设置以实现我的代码或hack以达到我期望的方式工作。

In the mean time have a look at :- 同时,请看一下:

Open a URL in a new tab (and not a new window) using JavaScript 使用JavaScript在新标签页(而不是新窗口)中打开URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM