views:

276

answers:

1

Hello,

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  A: 

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.

Craig Stuntz
Ya.. You are right. Even I thought about it. But I want to show preview of the page before the actual print. So, That forced me to use Hide and show. Which I personally hate to do. Do you have any thoughts on how to do?
kalyan
Open the preview in a new window, which uses the print style sheet except without `media="print"`.
Craig Stuntz
Thanks Craig. for your reply. Till now I always thank people personally by name.. And I thought that is the better way to say thank you. But I will make sure I will mark as answer from now on..
kalyan