打印CSDN博客内容JS

https://blog.csdn.net/jdy_lyy/article/details/102923471

使用如下代码,先进入到打印界面

(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();
$(".csdn-side-toolbar").remove();
$(".tool-box").remove();
$("main").css(‘display‘,‘content‘); 
$("main").css(‘float‘,‘left‘); 

$("tool-box").remove();
})();

  

使用如下代码,进行正式打印

https://www.jianshu.com/p/5b43a2a8081e

(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".csdn-side-toolbar,.template-box,.reward-user-box").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box,#dmp_ad_58").remove();
$("aside").remove();
$(".tool-box").remove();
$("main").css(‘display‘,‘content‘);
$("main").css(‘float‘,‘left‘);
$("#mainBox").css(‘width‘,‘1048px‘);
$("#mainBox").css(‘margin-left‘,‘0px‘);
$("#mainBox").css(‘margin-right‘,‘0px‘);
//$("[class=‘main_father clearfix d-flex justify-content-center‘]").css("width","1048px");
$(".main_father.clearfix.d-flex.justify-content-center").css("width","1048px");
window.print();
$("tool-box").remove();
})();

  

打印CSDN博客内容JS

上一篇:CSS选择器


下一篇:Three.js DeviceOrientationControl源码解析