1、先引入print.js
(function ($) {
var printAreaCount = 0;
$.fn.printArea = function () {
var ele = $(this);
var idPrefix = "printArea_";
removePrintArea(idPrefix + printAreaCount);
printAreaCount++;
var iframeId = idPrefix + printAreaCount;
var iframeStyle = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;';
iframe = document.createElement('IFRAME');
$(iframe).attr({
style: iframeStyle,
id: iframeId
});
document.body.appendChild(iframe);
var doc = iframe.contentWindow.document;
$(document).find("link").filter(function () {
return $(this).attr("rel").toLowerCase() == "stylesheet";
}).each(
function () {
doc.write('<link type="text/css" rel="stylesheet" href="'
+ $(this).attr("href") + '" >');
});
doc.write('<div class="' + $(ele).attr("class") + '">' + $(ele).html()
+ '</div>');
doc.close();
var frameWindow = iframe.contentWindow;
frameWindow.close();
frameWindow.focus();
frameWindow.print();
}
var removePrintArea = function (id) {
$("iframe#" + id).remove();
};
})(jQuery);
2、写入html代码,以table表格当分页,table里的style不能删掉,不然实现不了分页
<a href="javascript:doPrint();">打印</a> <div id="print"> <table style="page-break-after:always">打印1</table> <table style="page-break-after:always">打印2</table> <table style="page-break-after:always">打印3</table> </div>
3、引入jquery,再写入以下方法
function doPrint() {
$("#print").printArea();
}
wordpress文章nextpage分页最后添加“下一页”按钮
上面是“js实现局部分页打印”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_131.html
workflows工作流
在森林中心有一座蛇形的房子ComfyUI工作流
一只透明老虎骨骼标本ComfyUI工作流
一个浑身皮毛看起来像丘巴卡的3d动漫人物
令人着迷的一只老虎ComfyUI工作流
文生图工作流:图片合并comfyui工作流
彩色雄鹰玉雕ComfyUI工作流
停在音乐节露营地的一辆复古大众巴士由羊毛制成
一个超凡脱俗的女明星的特写镜头ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

用svg画出游泳池动画效果
SVG路径动画效果
会议人员60s签到倒计时插件
js实现下雪特效
纯css制作卡通头像(随鼠标转头)
3d空间行走效果
3d文字360度旋转
利用CSS3代码编写45款按钮效果










