c# - 无法使用 c#/ASP.Net 在 Chrome 中打开弹出窗口
问题描述
我有基于文件夹内容动态构建一系列超链接的代码。当我运行代码并单击链接时,会弹出一个窗口,但它是空白的。这是使用 Chrome 的 ASP.Net 4.6.1 网页中的 C#。这是我的代码:
TableRow newRow = new TableRow();
string foldername = Convert.ToString(Request.QueryString["oid"]) + "\\";
string pathString = Server.MapPath("~/Files/");
string completePath = Path.Combine(pathString + foldername);
if (Directory.Exists(completePath))
{
string[] files = Directory.GetFiles(completePath);
int cellCount = 0;
foreach (string foundfile in files)
{
TableCell newCell = new TableCell();
newCell.BorderColor = Color.Black;
newCell.BorderWidth = Unit.Parse("1px");
string filename = Path.GetFileName(foundfile);
HyperLink hl = new HyperLink();
hl.NavigateUrl = completePath + filename;
hl.Text = filename;
hl.Target = "_blank";
hl.Attributes.Add("onclick", "window.open(this.href, 'child', 'height=400, width=600,scrollbars'); return false");
if (cellCount == 0 || (cellCount % 3) == 0)
{
newRow = new TableRow();
taSpecs.Rows.Add(newRow);
}
newCell.Controls.Add(hl);
newRow.Cells.Add(newCell);
cellCount++;
}
}
文件存在,如果我将 URL 从链接之一复制到文件资源管理器,它会毫无问题地打开文件。Chrome 已关闭弹出窗口阻止程序。我究竟做错了什么?
解决方案
推荐阅读
- python - Python,OpenSSL:自签名证书生成
- django - 使用 Zappa 将 Geo Django 项目添加到 AWS Lambda。获取 OSError:无法打开共享对象文件:没有这样的文件或目录
- ios - 将用户模型保存在 UserDefaults 中并将存储的用户附加到数组
- javascript - 异步/同步:如何确定 Javascript 函数将在 for 循环后执行?
- python-3.x - 使用 ID 列表仅抓取不包含推文文本的推文元数据
- websphere - 使用 Angular 6 的 Websphere 门户
- android - 我应该在 Firestore 中存储什么,以便我可以根据从自动完成位置 api 获取的详细信息获取数据?
- sql-server - 比较内存与磁盘表的 SQL Server 性能
- angular - How to use @fontawesome social network icons on angular 7?
- ffmpeg - HTTP 流式桌面到浏览器的巨大延迟