Chrome On Adroid OS出现问题,但功能未在加载时运行

时间:2019-02-08 16:41:28

标签: javascript android google-chrome

因此Im为我的Andorid手机制作了一个POS打印解决方案,以便可以打印到蓝牙打印机。使evreything正常工作,但是希望它在页面加载时自动打印,而不必单击我制作的打印按钮。

<HTML>
 <script  type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>  
 <script>


function sendToQuickPrinterChrome(){
   var commandsToPrint =
                "<CENTER><LOGO2>" +
                "<BOLD><CENTER><BIG> SAINT JIMMY'S COFFEE <BR>" +
                "<CENTER>Inventory Count<BR>" +
                "<CENTER>2019-01-15<BR>" +
                "<CENTER>416-xxx-xxxx<BR>" +
                "<CENTER>E-mail@email.com<BR>" +
                "<CENTER>Receipt #:002- 15-0005852<BR>" +
                "<CENTER>Store:Test Store<BR>" +
                "----------------------------------------------------------------\n" +
                "Flavour                               BoxCount  OpenPods  Added\n" +
                "Amaretto Almond                              5         4      0\n" +
                "Bavarian Chocolate                           6         2      0\n" +
                "Chocolate Raspberry                          5         2      0\n" +
                "Coconut Cream                                5         7      0\n" +
                "Cognac                                       2         3      0\n" +
                "Dark Roast                                   0         0     10\n" +
                "Decaf                                        5        12      0\n" +
                "Earl Grey Tea                                6         5      0\n" +
                "French Caramel                               5         8      0\n" +
                "French Vanilla                               4         8      0\n" +
                "Green Tea                                    6         1      0\n" +
                "Hazelnut                                     4         1      0\n" +
                "Holiday Flavours                             0         0      0\n" +
                "Hot Chocolate                                0        12      7\n" +
                "Irish Whisky & Cream                         4         3      0\n" +
                "Jamaican Me Crazy                            4        13      0\n" +
                "Light Roast                                  5         5      0\n" +
                "Medium Roast                                 0         0     10\n" +
                "Orange Pekoe Tea                             1        13      5\n" +
                "Peppermint Tea                               5        11      0\n" +
                "Pumpkin Spice                                0         2      0\n" +
                "Tiramisu                                     2         3      0\n" +
                "----------------------------------------------------------------\n" +
                "Total:                                      74       115     32<br>\n" +
                "Previous Count:;;1452\n" +
                "Current Count:;;1003\n" +
                "Total Pods Sold:;;449\n" +
                "Unit Price:;;$1.04\n" +
                "Total Charge:;;$466.96\n" +
                "<BR>\n" +
                "<BR>\n" +
                "<CUT>\n";
var textEncoded = encodeURI(commandsToPrint);
    window.location.href="intent://"+textEncoded+"#Intent;scheme=quickprinter;package=pe.diegoveloper.printerserverapp;end;";
}
$( document ).ready(function() {
    sendToQuickPrinterChrome();   
 //  console.log( "ready!" );

});
</script>


<a onclick="sendToQuickPrinterChrome();">
    <br>Print Button</a>

</HTML>

所以我的“打印按钮”可以正常工作。 如果我在Android上使用FireFox,则在页面自动加载时可以打印,但可以,但是如果我使用Chrome,则它不会在加载时启动该功能,我不知道为什么。

1 个答案:

答案 0 :(得分:0)

在Chrome浏览器或某些其他Android浏览器(如Samsung Internet)中将无法使用。这是一项安全功能,可保护用户免受垃圾邮件的侵害。如果不单击按钮,您将无法实现。我希望这对您来说不是一个大问题,但这是不可能的。