Window.onbeforeprint和Window.onafterprint同时被触发 [英] Window.onbeforeprint and Window.onafterprint get fired at the same time

查看:2632
本文介绍了Window.onbeforeprint和Window.onafterprint同时被触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了onbeforeprint,我修改了我的html代码,现在一旦我完成打印选择打印按钮,我想要onafterprint被触发,但它没有。

I have defined onbeforeprint and i modify my html code and now once i finish printing that is on select of print button i want the onafterprint to be fired but it does not.

相反,当我按Control + Print按钮时,首先触发onb​​eforeprint,然后触发onafterprint事件,然后显示打印对话框。

Instead when i press the Control + Print button the onbeforeprint is fired first and then the onafterprint event and then print dialog is shown .

有没有办法点击打印按钮后,以某种方式对我的HTML进行更改?

Is there any way i could in some way do changes to my html after the "Print" button is clicked ?

使用IE -9浏览器,代码如下
代码

Am using IE -9 browser and the code is as follows Code

<script type="text/javascript">
    window.onbeforeprint = function () {
        alert('Hello');
    }
    window.onafterprint = function () {
        alert('Bye');
    }
</script>

谢谢&请问,
Francis P。

Thanks & Regards, Francis P.

推荐答案

onbeforeprint 对话框出现,允许人们更改html等等。

onbeforeprint fired before dialog appears and allows one to change html and so on.

onafterprint 被触发只是之前出现对话框。甚至不可能知道文件是否实际打印或用户取消。打印完成后(如果开始)不用说了。

onafterprint is fired just before dialog appears. It is not even possible to know, whether document was actually printed or user canceled it. Needless to say about when printing finished (if started at all).

再次:没有事件可以跟踪打印对话框中发生的任何事情,即回答你的问题是 no

Again: no event is available to track anything happened in print dialog, i.e. answer to your question is no.

此外,我希望您的需求永远不会被实现,因为这样可以让用户感到沮丧。他/她要求打印一份文件,但有所不同。

Moreover, I hope what your need will never be implemented, cause this allows to frustrate user. He/she asks to print one document, but got something different.

这篇关于Window.onbeforeprint和Window.onafterprint同时被触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆