0

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.

zx81
  • 41,100
  • 9
  • 89
  • 105
bluwater2001
  • 7,829
  • 5
  • 24
  • 21
  • You've asked five questions, never voted, and have only accepted one answer. If you find the advice at this site helpful, you should vote for any answers you find helpful (by clicking the up arrow by the answer) and accept the most helpful answer. It's a way to say "thank you!" – Craig Stuntz Dec 10 '09 at 22:01

1 Answers1

1

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
  • 125,891
  • 12
  • 252
  • 273
  • 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? – bluwater2001 Dec 10 '09 at 22:12
  • Open the preview in a new window, which uses the print style sheet except without `media="print"`. – Craig Stuntz Dec 10 '09 at 22:15
  • 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.. – bluwater2001 Dec 11 '09 at 16:17