2

I'm wondering what is happening when you print an html page in the different browsers (IE9++).

Do the different browsers refresh the page re-executing the javascript (implying re-executing some servers calls) ?

How to know you're refreshing -if - for a print in JS ?

Philipp
  • 67,764
  • 9
  • 118
  • 153
ic3
  • 7,917
  • 14
  • 67
  • 115

1 Answers1

3

No, the page is not refreshed when printed. You can however apply a special stylesheet that is only valid for print use. For example:

@media print {
    p { font-family:serif; color: black; font-size:12pt }
}

See also http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/

Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
  • Sebastian, the question is also what happens with html events when you apply the css. Are they triggered ? – ic3 Jan 15 '14 at 13:03
  • What do you mean by html events? – Sebastian Wramba Jan 15 '14 at 13:07
  • all events we catch with js (e.g. onclick) : http://www.w3schools.com/tags/ref_eventattributes.asp – ic3 Jan 15 '14 at 13:09
  • As long as no one clicks something, why should `onclick` be triggered? I guess the `onbeforeprint` and `onafterprint` will be triggered, but everything else? Don't think so. – Sebastian Wramba Jan 15 '14 at 13:13
  • indeed for onclick :-), just wondering if there is a resizing event send (e.g. print page size is not the same as the screen one) or others event when applying the css (hide/unhide) – ic3 Jan 15 '14 at 13:16
  • Good question. I found another question concerning the resize event: http://stackoverflow.com/questions/3538260/trigger-resize-event-on-print Empirical result: Sometimes ;) – Sebastian Wramba Jan 15 '14 at 13:21