简体   繁体   English

打开多个浏览器标签,但只有一个会打开

[英]opening multiple browser tabs but only one will open

I have a scenario where I loop through a data set (max of 6 records) and then open a new browser tab for each record - each tab shows an invoice for one of the records - not the best design but it's what was requested. 我有一个场景,我遍历一个数据集(最多6条记录),然后为每条记录打开一个新的浏览器选项卡-每个选项卡都显示其中一条记录的发票-不是最好的设计,但这是所要求的。

I'm using the code below within a foreach to build a url and open a new browser tab, the problem is it loops through ok but only ever opens 1 new tab. 我在foreach中使用下面的代码来构建url并打开一个新的浏览器选项卡,问题是它会循环遍历,但是只能打开1个新选项卡。 Every other thing happening in the loop works so the problem seems to be with the code. 循环中发生的所有其他事情都起作用,因此问题似乎出在代码上。 It opens the first tab for the first record then no more after that. 它将为第一个记录打开第一个选项卡,之后将不再显示。 Can anyone comment on what's wrong? 谁能评论出什么问题了?

            string pageurl = "Label.aspx?booking=" + v.booking + "&pallet=" + v.palletId;
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + pageurl + "','_blank')", true);

You can only have one startup script. 您只能有一个启动脚本。 Try putting all of your window.open calls in a single script; 尝试将所有window.open调用都放在一个脚本中;

//This code inside loop
string pageurl = "Label.aspx?booking=" + v.booking + "&pallet=" + v.palletId;
string script += "window.open('" + pageurl + "','_blank'); "

//This code outside loop
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", script, true);

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

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