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);
常见问题FAQ
- 【点击查看】免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 【点击查看】提示下载完但解压或打开不了?
- 【点击查看】开通终身至尊下载源码 “不完整” 或 “不能用” 怎么办?
- 【点击查看】开通终身会员能下载全站资源码?