【发布时间】:2010-09-27 08:03:58
【问题描述】:
在我的代码中,我使用 JavaScript 在 ASPX 页面上触发 window.open() 事件。我在此页面的Page_Load() 事件中输出一个文件:
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\";");
outputStream.WriteTo(Response.OutputStream);
outputStream.Flush();
outputStream.Close();
Response.Flush();
Response.Close();
之后我想关闭这个弹出窗口。但是因为我改变了我的响应类型,我不能在 JavaScript 中执行window.close()。它只会附加到提供给用户的文件中。这个线程是我发现解决我的问题的最合适的来源:
Closing window after export to excel
但是给出的答案对我没有帮助,所以我基本上被卡住了。我不想告诉用户手动关闭窗口。你知道如何实现我的目标吗?
【问题讨论】: