最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using window.print() to print a different stylesheet without restyling the page? - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question asked Feb 18, 2011 at 8:12 AKorAKor 8,89229 gold badges88 silver badges139 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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" />
发布评论

评论列表(0)

  1. 暂无评论