0

我正在使用以下示例代码,该代码在单击按钮时在本地打印,但希望它在页面加载时自动打印。

这是示例代码:

        <script>
            $(document).ready(function () {
                $("#printBtn").click(function () {
                    //1. perform server side task
                    $.ajax({
                        url: "CreateTextFileHandler.ashx", success: function (txtFileName) {
                            alert("The text file: " + txtFileName + " was created at server side. Continue printing it...");

                            //2. Print the created text file specifying the file name

                            jsWebClientPrint.print('useDefaultPrinter=' + $('#useDefaultPrinter').attr('checked') + '&printerName=' + $('#installedPrinterName').val() + '&txtFileName=' + txtFileName);


                        }
                    });
                });
            });
        </script>

我想通过删除来更改它,$("#printBtn").click(function()以便在页面加载后无需用户干预即可运行。当我CreateTextFileHandler.ashx执行并执行警报时,但调用jsWebClientPrint不执行。

4

0 回答 0