处理思路
通过一个JS命令,将不需要的部分Remove掉,把CSS调整一下。
打印示例
CSDN较为固定,一般用来打印CSDN文章的方法如下:
(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove();
$("aside").remove();
$(".tool-box").remove();
$("main").css('display','content');
$("main").css('float','left');
window.print();
$("tool-box").remove();
})();
而博客园基本都是自定义的排版布局,较为复杂,本人个人的打印博客园文章:
(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove();
$("aside").remove();
$(".tool-box").remove();
$("main").css('display','content');
$("main").css('float','left');
$ ("#leftmenu").remove();
$ ("#div_digg").remove();
$("#content").css("margin-left","0");
window.print();
$("tool-box").remove();
})();