0

In a asp.net page, when click a button, I need generate an url and open it in new tab, I have done this by clientscript, code work fine for IE, but it looks window.open always open a new window instead of tab in chrome. how to make code work for chrome?

        var sb = new StringBuilder();
        sb.Append("<script type = 'text/javascript'>");
        sb.Append("window.open('");
        sb.Append(url);
        //sb.Append("','_blank');");
        sb.Append("');");
        sb.Append("</script>");

        ClientScript.RegisterStartupScript(this.GetType(), "script", sb.ToString());
seagull
  • 237
  • 1
  • 7
  • 19

2 Answers2

0

in google chrome, using the code :

window.open('myurl.com', '_blank');

By using the second part of it as a target, it should target a blank page and a new tab.

-1

Opening of new tab is User Setting in browsers which can be changed only by humans. And this cannot be changed by Javascript for security purposes.

pokrate
  • 3,954
  • 7
  • 30
  • 36