Determine whether browser supports printing

前端 未结 3 1840
野性不改
野性不改 2020-12-03 09:15

I think the answer to this is almost certainly \"no\", because I\'ve done a little testing and searching around, but is there any trick to detect whether window.print(

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 09:26

    The print() method is synchronous. This makes it possible to do the aftermath in order to decide wether a print dialog has been shown

    var start = +new Date();
    window.print();
    var delta = + new Date() - start;
    console.log(delta);
    if (delta > 100) { console.log('It worked'); }
    

提交回复
热议问题