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

javascript - Change print style (landscape , portrait) using jquery - Stack Overflow

programmeradmin0浏览0评论

Currently I have create 2 css file , to simplify : the main difference between them are:

print.css

@page {
  size: landscape;
}

print_single.css

@page {
  size: portrait;
}

For the html file , it quote one of the css first

<link rel="stylesheet" id ="printCSS" href="css/print.css" type="text/css" media="print" />

Then if it is printing single page , I use jquery to change the path of the css file, otherwise , it will print in landscape :

    $(doc).ready(function(){
      $('#singlePrint').click(function(){
      $('#printCSS').attr('href','css/print_single.css');
    });    
});

The problem is , it seems only work in Chrome, I tried it on firefox and ie, the css file path is changed, but the css file is not reload , how to fix the problem ? thanks.

Currently I have create 2 css file , to simplify : the main difference between them are:

print.css

@page {
  size: landscape;
}

print_single.css

@page {
  size: portrait;
}

For the html file , it quote one of the css first

<link rel="stylesheet" id ="printCSS" href="css/print.css" type="text/css" media="print" />

Then if it is printing single page , I use jquery to change the path of the css file, otherwise , it will print in landscape :

    $(doc).ready(function(){
      $('#singlePrint').click(function(){
      $('#printCSS').attr('href','css/print_single.css');
    });    
});

The problem is , it seems only work in Chrome, I tried it on firefox and ie, the css file path is changed, but the css file is not reload , how to fix the problem ? thanks.

Share Improve this question asked May 29, 2013 at 3:58 user1871516user1871516 1,0096 gold badges15 silver badges26 bronze badges 2
  • 1 Not all of the @page properties are supported by all the browsers. developer.mozilla/en-US/docs/Web/CSS/@page – user2417483 Commented May 29, 2013 at 5:10
  • Thanks. but I tried on IE8 and FX. latest ver. It should be support? – user1871516 Commented May 29, 2013 at 6:22
Add a ment  | 

1 Answer 1

Reset to default 3

@page{size: landscape;} will not support in firefox. Alternative way is to use this in css class

-webkit-transform: rotate(-90deg); -moz-transform:rotate(-90deg);
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
发布评论

评论列表(0)

  1. 暂无评论