Wait until print is complete - Jquery Asp.net MVC

1.1k views Asked by At

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.

1

There are 1 answers

3
Craig Stuntz On BEST ANSWER

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.