在页面到达window.print()之前执行函数 [英] Executing function before page gets to window.print()

查看:340
本文介绍了在页面到达window.print()之前执行函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调用window.print()的页面;在页面的底部。我无法访问window.print();它由服务器生成,我无法触摸它。基本上是因为IE我需要在打印对话框出现之前执行一些javascript,但是在页面加载之后。我不能这样做因为它一旦到达window.print();出现打印对话框。我仍然需要打印,但首先我需要运行myFunction()然后我可以运行window.print();

I have a page that calls window.print(); at the bottom of the page. I have no way of accessing the code around window.print(); Its generated by the server and I can't touch it. Basically because of IE I need to execute a bit of javascript before the print dialog comes up but after the page has loaded. I can't do this because as soon as it gets to window.print(); the print dialog comes up. I still need to print but first I need to run myFunction() then I can window.print();

<html><head></head><body></body><!--no access from here--><script>window.print();</script></html>


推荐答案

您应该可以像这样覆盖它。 。

You should be able to override it like so...

var _print = window.print;
window.print = function() {
  alert("Hi!");
  // do stuff
  _print();
}

这篇关于在页面到达window.print()之前执行函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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