You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.9 KiB
96 lines
2.9 KiB
<META http-equiv="content-Type" content="text/html;charset=UTF-8">
|
|
<div id="report">
|
|
|
|
</div>
|
|
|
|
<button onclick="print()">点击这里更新打印控件</button>
|
|
<br/>
|
|
<br/>
|
|
<br/>
|
|
<button onclick="clearReg()">清理打印控件注册表</button>
|
|
|
|
<SCRIPT LANGUAGE="JavaScript">
|
|
<!--
|
|
|
|
function clearReg(){
|
|
var shell = new ActiveXObject("WScript.Shell");
|
|
//var key1 = shell.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\360Safe\\test");
|
|
shell.RegWrite("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\ActiveX Compatibility\\{1663ed61-23eb-11d2-b92f-008048fdd814}\\Compatibility Flags",
|
|
"0","REG_DWORD");
|
|
}
|
|
|
|
function print(){
|
|
PrintPart('report');
|
|
}
|
|
|
|
function getPrintIframe(){
|
|
var ifr = document.getElementById("dx_print_iframe");
|
|
if(!ifr){
|
|
ifr = document.createElement("iframe");
|
|
ifr.id = "dx_print_iframe";
|
|
document.body.appendChild(ifr);
|
|
ifr.style.pixelWidth = 1;
|
|
ifr.style.pixelHeight = 1;
|
|
}
|
|
return ifr;
|
|
}
|
|
|
|
function PrintPart(controlId, isPortrait) //isPortrait =false 代表横打
|
|
{
|
|
//根据传入的内容生成一个iFrame并打印
|
|
var ifr = document.getElementById("dx_print_iframe");
|
|
if(!ifr){
|
|
ifr = document.createElement("iframe");
|
|
ifr.id = "dx_print_iframe";
|
|
document.body.appendChild(ifr);
|
|
ifr.style.pixelWidth = 1;
|
|
ifr.style.pixelHeight = 1;
|
|
}
|
|
|
|
var ifrdoc = ifr.contentWindow.document
|
|
ifrdoc.open();
|
|
ifrdoc.write("<BODY>");
|
|
ifrdoc.write("<object id='print_factory' style='display:none' classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='ScriptX.cab#Version=6,1,431,2'></object> ");
|
|
ifrdoc.write(document.getElementById(controlId).outerHTML);
|
|
ifrdoc.write("</BODY>");
|
|
ifrdoc.close() ;
|
|
|
|
setTimeout(function(){
|
|
var fc = ifrdoc.getElementById("print_factory");
|
|
if(fc.object){
|
|
alert("更新成功");
|
|
}else{
|
|
alert("更新失败");
|
|
}
|
|
}, 10000);
|
|
/*
|
|
//以下调用iframe中创建的打印控件实现打印
|
|
var fc = ifrdoc.getElementById("print_factory");
|
|
fc.printing.portrait = isPortrait; //是否横向打印
|
|
fc.printing.header = "" //页眉
|
|
fc.printing.footer = "" //页脚
|
|
fc.printing.paperSize = "A3";
|
|
//fc.printing.Print(false);
|
|
fc.printing.Preview();
|
|
// document.body.removeChild(ifr);
|
|
*/
|
|
}
|
|
/*
|
|
function preview(controlId, isPortrait){
|
|
var newwin=window.open('','','');
|
|
newwin.opener = null;
|
|
newwin.document.write("<BODY>");
|
|
newwin.document.write("<object id='print_factory' style='display:none' classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='ScriptX.cab#Version=6,2,433,14'></object> ");
|
|
newwin.document.write(document.getElementById(controlId).outerHTML);
|
|
newwin.document.write("</BODY>");
|
|
newwin.document.close();
|
|
|
|
var fc = newwin.document.getElementById("print_factory");
|
|
fc.printing.portrait = isPortrait; //是否横向打印
|
|
fc.printing.header = "" //页眉
|
|
fc.printing.footer = "" //页脚
|
|
fc.printing.Preview();
|
|
setTimeout(function(){newwin.close();}, 2000);
|
|
}//*/
|
|
//-->
|
|
</SCRIPT> |