如何在按钮上打开多个浏览器选项卡单击? [英] How Would I Open Multiple Browser Tab On Button Click?

查看:83
本文介绍了如何在按钮上打开多个浏览器选项卡单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

请帮我解决这个问题。



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>


这篇关于如何在按钮上打开多个浏览器选项卡单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆