處理思路
通過一個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();
})();