如何在按钮上打开多个浏览器选项卡单击?

问题描述:

我正在尝试打开多个浏览器标签,但它被浏览器阻止。

请帮我解决这个问题。



I am trying to open open multiple browser tab but it is blocked by browser.
please help me to solve this problem.

for (int i = 0; i < rptrsearchschool.Items.Count; i++)
{
  CheckBox chk = (CheckBox)rptrsearchschool.Items[i].FindControl("chkList");
    if (chk.Checked)
    {
      int i1 = Convert.ToInt32(chk.Attributes["Text"].ToString());
      string url = "MYPage.aspx?UserID=" + i1;
     Response.Write( "<script> window.open( '"+url+"','_blank' ); </script>");
     }
}

所有人都会以这种方式打开新窗口/标签现代浏览器弹出!原因是open命令的来源不是单击链接而是一些JavaScript函数。

允许或阻止此类弹出由最终用户决定并可以从浏览器设置进行配置但不能绕过代码...

唯一的办法就是直接从按钮的点击事件中打开客户端的新窗口...

Opening new window/tab in such way is identified by all modern browsers as popup! The reason is that the origin of the open command is not a click on a link but some JavaScript function.
To allow or block such popup is up to the end user and can be configured from the browser settings but can not bypassed from code...
The only way is to do it is to open the new windows from the client directly from the click event of the button...
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <input id="Button1" type="button" value="button" onclick="multiopen()" />

    <script type="text/javascript">
        function multiopen() {
            window.open('url1', '_blank');
            window.open('url2', '_blank');
            window.open('url3', '_blank');
        }
    </script>
</body>
</html>