如何在网络路径文档客户端打印

时间:2018-09-20 17:49:28

标签: javascript jquery printing

我的文件存储在NAS网络中。现在,我想在Internet Explorer Edge中使用javasrcipt打印这些文档。以下是我尝试执行但无法打印的代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebPrintTest.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>

    printPdf = function (url) {
        var iframe = this._printIframe;
        if (!this._printIframe) {
            iframe = this._printIframe = document.createElement('iframe');
            document.body.appendChild(iframe);

            iframe.style.display = 'none';
            iframe.onload = function () {
                setTimeout(function () {
                    iframe.focus();
                    iframe.contentWindow.print();
                }, 1);
            };
        }

        iframe.src = url;
    }

    printPdf("\\ad\NAS\PrintDoc\Sample.docx");

</script>
</head>
<body>
<form id="form1" runat="server">
    <div>
    </div>
</form>
</body>

我的代码或方法有什么问题?

我收到错误消息

0x800a138f - JavaScript runtime error: Unable to get property 'appendChild' of undefined or null reference

 document.body.appendChild(iframe);

0 个答案:

没有答案