Executing function before page gets to window.print()

前端 未结 4 896
慢半拍i
慢半拍i 2020-12-16 03:19

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 tou

4条回答
  •  鱼传尺愫
    2020-12-16 04:02

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

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

提交回复
热议问题