0

I want to print webpage that support CSS using JavaScript, and here is my simple script:

print.css:

@media print {
 body { background-color:red;}
 }

webpage.html:

<HTML>
<head>
<link rel="stylesheet" type="text/css" href="print.css" media="print" />
</head>
<BODY>
          Hello World!
</BODY>
</HTML>

Then I try out it, why the result (the background of my webpage) still give me white? I printed it using PDF creator.

Can anyone help me?

psubsee2003
  • 8,563
  • 8
  • 61
  • 79
Plipus Tel
  • 666
  • 3
  • 13
  • 23

1 Answers1

1

IF a user has "Print Background colours and images" turned off in their print settings, no CSS will override that, so always account for that. This is a default setting.

Once that is set so it will print background colours and images, what you have there will work.

It is found in different spots.

In IE9 it's found in Print->Page Options under Paper options

In FireFox it's in Page Setup -> [Format & Options] Tab under Options.

Joan Caron
  • 1,969
  • 18
  • 21