• 微信号:Zh-y9213
您当前的位置:爱资源分享网 > > 网站源码 > 网站制作

javascript打印csdn/cnblogs去除无用内容方法

栏目:网站制作时间:2021-07-09 14:56阅读数:59人阅读

javascript打印csdn/cnblogs去除无用内容方法,搜索参考网上代码,很多要么页面打印不全、要么文字被切。
1. 进入页面,按F12,在console输入以下代码:
cnblogs博客园:

(function(){
'use strict';
$("#comment_form, #header, #leftmenu, #big_banner, #footer, #blog_post_info_block, #sideBar").remove();
$("#content").css('margin','0');
$("body").css('margin','0').css('padding','2px');
$("#mainContent").css('width','100%');
window.print();
})();

CSDN:

(function(){
'use strict';
$(".toolbar-inside, .blog_container_aside, .csdn-side-toolbar , .more-toolbox, .recommend-box insert-baidu-box, .blog-footer-bottom").remove();
$("main").css('display','content');
$("main").css('float','left');
$("main").width(1080);
$("#mainBox").width("100%");               
window.print();
})();

2. 其他类似,如有改版,页面右键检查要去除的部分,查看源码,按选择器去除相关部分:
.xxx      类选择器,以class=xxx
#xxx    ID选择器,以id=xxx
3. CSDN打印时切文字,因其width设置与打印显示不一致,按下设置:

$("main").width(1080);



资源均来自第三方,谨慎下载,前往第三方网站下载

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:737597453@qq.com