How to print web page with a different stylesheet other than print.css

拟墨画扇 提交于 2019-12-25 07:50:00

问题


I've already got a print.css that manages print outs of a page but I want to create basic-print.css which prints out very basic information. How would I create a button that prints the web page out using basic-print.css instead of print.css?

Thanks in advance.

Edit: quick example of what I'm trying to achieve...

  1. CTRL+P (or File > Print) == Use print.css
  2. Hit button called "Basic Print" == Use basic-print.css

回答1:


This is just an idea, but have you tried loading the basic-print.css file with JavaScript?

I'm thinking of something like (using the jQuery library):

$(document).ready(function(){
    $('#print-basic-button').click(function(){
       $('link').first().removeAttr('href').attr('href', 'basic-print.css');
    });
});


来源:https://stackoverflow.com/questions/28897149/how-to-print-web-page-with-a-different-stylesheet-other-than-print-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!