8
<link rel="stylesheet" href="printStyle.css" media="print" />

This line fixes the print preview for Chrome / IE7 and IE9 but it doesn't seem to work with IE8.. Has anyone got any idea?

After some comments I realized it's a IE8 problem. I've been goolgeing around and came up with adding the following on the top of my section:

<!--[if lt IE 9]>
    <script src="http://html5shiv-printshiv.googlecode.com/svn/trunk/html5shiv-printshiv.js"></script>
<![endif]-->

This makes it possible to use a general stylesheet with @media print {}.

This, again, works in IE7 / 9 and not in IE8.. Can't, again, really figure out why. But the printshiv does work otherwise I wouldn't be able to get the correct print preview in IE7.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
GregD
  • 1,884
  • 2
  • 28
  • 55
  • If the problem is not related to the template code, then providing template code in your question is not helpful. – cimmanon Dec 02 '13 at 13:49
  • When you render the site in IE8 - can you check if it's using IE8 standards in the browser ? – Ani Dec 02 '13 at 16:47
  • 1
    what is your question? how to get print preview in ie8 to work? – albert Dec 03 '13 at 00:05
  • It was using the IE8 standards. I've posted the solution below. Can't and don't understand why, but it works. – GregD Dec 03 '13 at 10:01

2 Answers2

6

I finally figured out what went wrong (with a lot of luck..)

For some reason the following css didn't do the job:

#divID1, #divID2, #divID3 { display: none; }

Changed it to:

#divID1 {
   display: none;
}

#divID2 {
   display: none;
}

#divID3 {
   display: none;
}

and now it works in IE8. Can't really figure out why..

GregD
  • 1,884
  • 2
  • 28
  • 55
  • The IDs sound like those are `div` elements you're styling. That makes it even weirder why it wouldn't work since IE8 supports them just fine without the HTML5 shiv. – BoltClock Dec 03 '13 at 10:04
  • It aren't only div's that i'm selecting. This was just a mock of the situation. I'm also trying to hide tables etc, but then again.. Why would IE8 have got a problem with the display:none for a table with an id. And why wouldn't it have a problem if I separate all the "select" statements! – GregD Dec 03 '13 at 10:08
  • That I can't answer either. Generally IE8 doesn't have trouble with ID selectors, but once you start tossing polyfills at it it can start to choke. That's old IE for you. – BoltClock Dec 03 '13 at 10:09
  • I even deleted the html5shiv. And it still works in IE7 (with: @media print { .. }), which I also don't really understand. And indeed, normally even IE8 should be able to select some ID's ^^. – GregD Dec 03 '13 at 10:13
-4

This is not supported in IE8. Possible workarounds are suggested at IE8 support for CSS Media Query. Hope this helps. :-)

Community
  • 1
  • 1
  • // media queries are for responsive design, not print layouts – Rápli András Dec 02 '13 at 15:36
  • 2
    @Rápli András: That's nonsense. `media="print"` was valid before media queries existed, and is a valid media query today. Media queries weren't invented because of responsive design - it's the other way around. – BoltClock Dec 03 '13 at 10:05
  • This answer is also not quite right - IE8 doesn't support media queries but it does support media types that were introduced before media queries. – BoltClock Dec 03 '13 at 10:06