简体   繁体   English

窗口打印方法在ipad chrome浏览器中不起作用

[英]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. 在所有浏览器中都可以使用,但是在ipad chrome浏览器中不执行任何操作(不打开打印对话框)。

How can I solve this problem? 我怎么解决这个问题?

However if I do manually print with chrome settings print then its working. 但是,如果我确实使用chrome设置进行手动打印,则可以正常工作。

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. 在SO秀(多问题, 123 ),它目前还无法在iOS版Chrome打印,由于苹果对使用替代浏览器引擎的政策。

Another solution is to use a third-party printing service: http://www.printfriendly.com 另一种解决方案是使用第三方打印服务: http : //www.printfriendly.com

It's a chrome bug/feature. 这是一个Chrome错误/功能。 window.print is available, it works and do nothing. window.print是可用的,它无法执行任何操作。 Try this code : 试试这个code

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

The alert will not be shown. 该警报将不会显示。 Also class UIWebView can use UIKit Printing API UIWebView类也可以使用UIKit Printing API

PS Chrome using UIWebView . 使用 UIWebView PS Chrome。

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM