javascript - 如何打印网络路径文档客户端
问题描述
我有文件存储在 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);
解决方案
推荐阅读
- typescript - 当我收到 post 请求时如何运行 python
- amazon-web-services - 根据 serverless 错误信息定位 cloudwatch 错误日志
- node.js - Node+MongoDB基于平均值的高效查询
- sql-server-2012 - 为什么 LOGIN7 使用 TDS 协议返回空回复
- java - 本地主机上的服务器 Tomcat 9.0 服务器无法启动
- asp.net - 如何在asp.net的文本框中插入时间
- java - 访问 src 文件夹中的 txt 文件
- python - python for循环访问序列值的“in”,其中if语句访问序列索引的“in”,为什么不一致?
- google-sheets - 根据条件复制标签的数组公式
- javascript - 添加 Loader 直到 stl 图像加载 PHP