AKor
AKor

Reputation: 8892

Using window.print() to print a different stylesheet without restyling the page?

I have a print button on my page that will run window.print(), it just prints the page exactly. Is there a way to pass a parameter to that function so that it will print my page with the stylesheet print.css rather than style.css, without necessitating a page refresh?

Upvotes: 2

Views: 4397

Answers (1)

SergeS
SergeS

Reputation: 11799

In your css put any print specific CSS rules into

@media print{

}

And css rules for displaying into

@media screen, projection, tv{

}

HTML will look this

  <link href="default.css" rel="stylesheet" type="text/css" media="all" />
  <link href="print.css" rel="stylesheet" type="text/css" media="print" />

Upvotes: 10

Related Questions