Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to open open multiple browser tab but it is blocked by browser.
please help me to solve this problem.

C#
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>");
     }
}
Posted
Comments
ZurdoDev 12-Nov-14 8:06am    
If the browser is blocking them, I'm not sure what else you can do.

1 solution

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...
HTML
<!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>
 
Share this answer
 
v2
Comments
ZurdoDev 12-Nov-14 7:57am    
I don't see how this helps the user. OP said the browser blocks the windows.
Kornfeld Eliyahu Peter 12-Nov-14 8:02am    
Ops...
MAK09 12-Nov-14 8:27am    
But i am creating url dynamically.
Kornfeld Eliyahu Peter 12-Nov-14 8:29am    
So you will have to render multiopen dynamically - no other way to overcome popup-blocker!
MAK09 12-Nov-14 22:14pm    
can you help me to convert above code in javascript. as i don't know javascript. Above is repeater in that i have checkbox. so when i select 2 checboxes after button click each checkbox gives particular id. above code is working but pop blocker. please help me to convert in javascript

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900