window print method is not working in ipad chrome browser

天涯浪子 提交于 2019-12-23 07:48:06

问题


I have the following code:

<input type="button" value="Print" onclick="window.print(); return false;">

Which works in all browsers but it is doing nothing ( not opening print dialog box ) in ipad chrome browser.

How can I solve this problem?

However if I do manually print with chrome settings print then its working.


回答1:


Multiple questions on SO show (1, 2, 3) that it's currently not possible to print in Chrome for iOS due to Apple's policy on using alternative browser engines.

Another solution is to use a third-party printing service: http://www.printfriendly.com




回答2:


It's a chrome bug/feature. window.print is available, it works and do nothing. Try this code:

try {
    window.print()
}catch(e) {alert(e.message)}

The alert will not be shown. Also class UIWebView can use UIKit Printing API

P.S. Chrome using UIWebView.




回答3:


Try this:

function goPrint(){
    window.print();
    if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
        window.location.reload();
    }
}


来源:https://stackoverflow.com/questions/24947993/window-print-method-is-not-working-in-ipad-chrome-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!