I have documents stored in NAS network. Now I want to print those documents using javasrcipt in Internet Explorer Edge. Below is the code which I am trying to execute but its not able to print
<%@ 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>
What's wrong in my code or approach?
I am getting error as
0x800a138f - JavaScript runtime error: Unable to get property 'appendChild' of undefined or null reference
at
document.body.appendChild(iframe);
User contributions licensed under CC BY-SA 3.0