js 如何判断window.print()打印成功

qq_35167499 2016-11-14 04:19:12
如题
 function preview(){
document.getElementById("J_submit_form").style.display = "none";
document.getElementById("foota").style.display = "none";
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();
window.document.body.innerHTML=bdhtml;
document.getElementById("J_submit_form").style.display = "block";
document.getElementById("foota").style.display = "block";
}

点击打印,怎么判断是打印成功了,小弟想要一个返回值,用来改变数据库的打印状态,求大神指点,谢谢!
...全文
2397 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
风谷玄 2019-06-28
  • 打赏
  • 举报
回复
我引用它这里面的捕获window.print()的窗口完成后的事件 https://zhidao.baidu.com/question/1819771570835857188.html?qbl=relate_question_5&word=%B5%F7%D3%C3window.print%28%29%B7%BD%B7%A8%2C%C8%E7%BA%CE%BB%F1%C8%A1%B4%F2%D3%A1%BB%F2%D5%DF%C8%A1%CF%FB%B5%C4%D7%B4%CC%AC
浪迹天涯-Jason 2016-12-04
  • 打赏
  • 举报
回复
直接ajax请求到action,在action中就可以打印。 或者用servlet时候,转换json格式的时候打印一下,有转换json格式的api可以使用
哈雷11111 2016-12-03
  • 打赏
  • 举报
回复
js捕获不到这个状态,判断不了的

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧