[英]ScriptX Print functionality is not working in IE8
I have a requirement of printing documents and I am using ScriptX for this purpose. 我需要打印文档,并且为此使用了ScriptX。 Everything works fine and prints the documents in IE11.But in IE8,I am getting an error,Error: The value of the property '$' is null or undefined, not a Function object. 一切正常,并且可以在IE11中打印文档。但是在IE8中,我收到一个错误消息,错误:属性“ $”的值为null或未定义,不是Function对象。
My printing code looks like this 我的打印代码如下所示
function PrintFunctionality(url, title,data)
{
if (!!navigator.userAgent.match(/Trident\/7\./)) {
//alert('ie browser');
var printWindow = window.open('', '', 'height=400,width=800');
var htmltext = '<html><head><title>' + title + '</title>';
htmltext += "<object id='factory' style='display:none' classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='http://localhost/smsx.cab#Version=7,5,0,20'></object>";
htmltext += "<script src='http://localhost/jquery-1.8.2.min.js'></script>";
htmltext += "<script src='http://localhost/meadco-scriptx-1.0.2.js' type='text/javascript'></script>";
htmltext += "<script type='text/javascript'>";
htmltext += "$(function () {";
htmltext += "if (MeadCo.ScriptX.Init()) {MeadCo.ScriptX.PrintPage(false);}});</script>";
htmltext += '</head><body>';
htmltext += data;
htmltext += '</body></html>';
printWindow.document.write(htmltext);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
return false;
}
};
and the installed version of script x in my system is: 我系统中脚本x的安装版本是:
The installed version of ScriptX is: 7.5.0.20 ScriptX的安装版本为:7.5.0.20
The installed version of Security Manager is: 7.5.0.20 安全管理器的安装版本为:7.5.0.20
The installed version of Print component is: 7.5.0.20 打印组件的安装版本为:7.5.0.20
Any thing to change in the code to work for IE8 ? 有什么需要更改代码才能适用于IE8的东西吗?
Background - there are a number of issues: 背景-存在许多问题:
In this scenario, jQuery and meaco-scriptx-1.0.2 offer no real benefit. 在这种情况下,jQuery和meaco-scriptx-1.0.2并没有真正的好处。
This is a temporary window that should be able to assume that ScriptX is already installed. 这是一个临时窗口,应该能够假定已经安装了ScriptX。 The answer/change to make it work in any version of IE is to go old-school: 使它在任何版本的IE中都可以使用的答案/更改是过时的:
function PrintFunctionality(url, title, data) {
var printWindow = window.open('', '', 'height=400,width=800');
var htmltext = '<html><head><title>' + title + '</title>';
htmltext += "<object id='factory' style='display:none' classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814'></object>";
htmltext += "<" + "script type='text/javascript'>";
htmltext += "function printDocument() { window.setTimeout('window.close()',3000); factory.printing.print(false); }</" + "script>";
htmltext += "</head><body onload='printDocument()'>";
htmltext += data;
htmltext += '</body></html>';
printWindow.document.write(htmltext);
printWindow.document.close();
return false;
}
Note that the window closes itself and it does after a delay that is deemed long enough for the print to have completed (spooled). 请注意,该窗口会自行关闭,并且会在被认为足以使打印完成(假脱机)的延迟后关闭。 It is a quirk of this scenario that you must call window.setTimeout() before calling factory.printing.print() or the timeout may not fire. 在这种情况下,您必须在调用factory.printing.print()之前先调用window.setTimeout(),否则可能不会触发超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.