87,904
社区成员
发帖
与我相关
我的任务
分享
<input type="button" class="btn btn-default" value="下载" onclick="btnPrint()" />
<script>
function btnPrint() {
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
};
</script>
$(function () {
$("#btnPrint").click(function () {
$.ajax({
url: '/SCRP0101/GetPrint',
type: "GET",
data: {},
success: function (data) {
//bdhtml =data; 直接连预览都显示不了
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
},
error: function (msg) {
alert('失败了,可能后台报错');
},
});
})
});
$(function () {
$("#btnPrint").click(function () {
$.ajax({
url: '/SCRP0101/GetPrintSendCar',
type: "GET",
data: {},
success: function (data) {
$("#disposeDiv").empty().append(data); //加这句就会打开table页面,不加接收不到table的返回值,打印是空白
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
},
error: function (msg) {
alert('失败了,可能后台报错');
},
});
})
});