等待打印完成 - Jquery Asp.net MVC

发布于 2024-08-14 02:55:36 字数 245 浏览 4 评论 0原文

我是新手。如果这是一个非常基本的问题,请原谅。我在 window.print() 上隐藏和显示 CSS。在 IE8 和 FF 上,页面执行停止,直到我对打印做出响应(打印或取消),然后它再次启动并完成页面加载。但在 IE6 和 IE7 上,页面加载不会等到我在打印对话框上做出响应。如何暂停页面执行,直到我在打印对话框上做出响应(打印或取消)?我不想使用 settimeout 因为它是针对特定时间的。如果我选择立即打印,则页面将不会加载,直到设置超时到期,反之亦然。请帮忙。

I am a newbie. please excuse me if it is a very basic question. I am hiding and showing CSS on window.print(). on IE8 and FF The page execution stops until i respond on print ( either print or cancel) and then it starts again and completes the page load. But on IE6 and IE7 the page load is not waiting until i respond on print dialog box. How can I pause Page execution until I respond ( either print or cancel) on the print dialog box? I do not want to use settimeout since it is for a specific time. If i choose to print immediately the page will not load untill settimeout expires and vice versa. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红颜悴 2024-08-21 02:55:36

不要在 window.print() 上隐藏和显示。它永远不会正常工作,并且会导致其他问题。

相反,使用单独的打印 CSS 文件:

<link href="/Content/Print.css" rel="stylesheet" type="text/css" media="print"/> 

该文件将定义打印样式,例如:

.noprint
{
    display: none !important;
}

然后您可以标记不想打印的元素:与

<img class="foo bar noprint" ...

window.print(),这适用于禁用 JavaScript 的情况。

Don't hide and show on window.print(). It will never work correctly, and will cause other issues.

Instead, use a separate, print CSS file:

<link href="/Content/Print.css" rel="stylesheet" type="text/css" media="print"/> 

This file will define styles for printing, like:

.noprint
{
    display: none !important;
}

You can then mark up elements you don't want to print:

<img class="foo bar noprint" ...

Unlike hiding and showing on window.print(), this works with JavaScript disabled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文