Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window print method is not working in ipad chrome browser

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.

like image 702
Navin Rauniyar Avatar asked Jul 25 '14 04:07

Navin Rauniyar


3 Answers

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

like image 174
jerone Avatar answered Sep 16 '22 12:09

jerone


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.

like image 23
Pinal Avatar answered Sep 18 '22 12:09

Pinal


Try this:

function goPrint(){
    window.print();
    if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
        window.location.reload();
    }
}
like image 32
wayofthefuture Avatar answered Sep 20 '22 12:09

wayofthefuture