二进制文件后关闭弹出窗口被发送到浏览器 [英] Close pop up window after binary file is sent to browser

查看:280
本文介绍了二进制文件后关闭弹出窗口被发送到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在页面写入二进制数据(PDF)后,向browswer关闭弹出窗口?

Is there a way to close a pop up window after the page writes binary data (PDF) to the browswer?

下面是详细内容:

每当我的网络appilcation需要打印,它会传递一些参数到一个弹出窗口,这将显示打印选项。当用户点击打印按钮,它会设置一个IFRAME,将调用,它的打印页面的src。

Whenever my web appilcation needs to print, it will pass some parameters over to a pop up window, which will display the print options. When the user clicks on the Print button, it will set the src of a iframe that will call the page that does the printing.

我要PDFConverter URL / HTML转换为PDF文件。在转换结束时,将写入二进制到浏览器。下面是一些code:

I have PDFConverter to convert URL / HTML to a pdf file. At the end of the converting, it will write the binary to the browser. Here are some code:

response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition",
"inline; filename=" + fileName + ".pdf; size=" + pdfBytes.Length.ToString());
response.Flush();
response.BinaryWrite(pdfBytes);
response.Flush();

完成之后,我将需要关闭弹出窗口。然而,它似乎是响应被刷新后,你不能做任何事情。任何想法?

After this is done, i will need to close the pop up window. However it seems like you can't do anything after the response is flushed. Any ideas?

在此先感谢!

安吉拉

推荐答案

以防万一其他人是否有同样的问题。这似乎为我工作的解决方案。

Just in case anyone else is having the same problem. This is the solution that seems to work for me.

我使用 jQuery开发的简单模态,以显示我的选项列表页。在这个页面上,我有一个窗口定时器运行每1秒要检查的服务器,如果打印作业已经完成。我用ajax了点。一旦工作完成,我更新会话变量,AJAX调用服务器会拿起会话值并关闭弹出窗口。

I use the jQuery Simple Modal to show my option list page. On this page, I have a window timer running every 1 second to check against the server if the print job is done. I use ajax for that. Once the job is done, I update the session variable, and the ajax call to the server will pick up the session value and close the pop up window.

这篇关于二进制文件后关闭弹出窗口被发送到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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