window.onload问题

浏览:1566 发布日期:2015/08/29 分类:求助交流 关键字: window.onload document.write
function printo(html){
    var aaa='<s'+'cript type="text/javascript" src="__PUBLIC__/js/jquery-1.8.2.js"></s'+'cript>';
    var nw='<scri'+'pt type="text/javascript">var URL="__URL__";function PrintInit(){print.InitPrint();print.companyName = "科技有限公司";print.seriesNo = "0245-5131-1852-5216";setParameters();}function Preview() {if (document.all.eprint.defaultPrinterName.length==0){alert("请先安装打印机,再执行此功能!");return;}document.all.eprint.InitPrint();document.all.eprint.marginTop=0;document.all.eprint.marginLeft=1;document.all.eprint.marginRight=1;document.all.eprint.marginBottom=0;document.all.eprint.pageWidth=40;document.all.eprint.pageHeight=30;document.all.eprint.header="";document.all.eprint.footer="";document.all.eprint.Preview();}function Print() {  if (document.eprint.defaultPrinterName.length==0){alert("请先安装打印机,再执行此功能!");return;}document.eprint.InitPrint();document.all.eprint.header="";document.all.eprint.footer="";document.all.eprint.Print(true);}function setParameters(){document.all.eprint.SetMarginMeasure(1);document.all.eprint.header="";document.all.eprint.footer="";document.all.eprint.pageHeight=30;document.all.eprint.pageWidth=40;document.all.eprint.marginTop = 5;document.all.eprint.marginLeft = 5;document.all.eprint.marginRight = 5;document.all.eprint.marginBottom = 5;}';
    var old="window.onload=Print;";
    var scr='</s'+'cript>';
    
    var printing='<input type="button" value="打印预览" onclick="Preview()"  class="button" style="position:absolute;left:10px;top:10px"><input type="button" value=" 打  印 " onclick="Print()"  class="button" style="position:absolute;left:100px;top:10px">';

    var newo=window.open('','newwin','height=300,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
    newo.document.write('<html><head><STYLE MEDIA="PRINT">.button {display:none;}</STYLE><STYLE MEDIA="SCREEN">.button {display:block;}</STYLE>\n');
    newo.document.write('<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/print.css"></head>\n');
    newo.document.write(aaa);
    newo.document.write(nw);
    newo.document.write(old);
    newo.document.write(scr);
    
    newo.document.write('<body onload="Print();"><object id="eprint" classid="clsid:CA03A5A8-9890-49BE-BA4A-8C524BBBB441" codebase="eprint.cab#Version=3,0,0,6" viewasext> </object>');
    newo.document.write(printing);
  newo.document.write(html);
  newo.document.write('</body></html>');  
}
document.write弹出的页,用window.onload执行某函数,却不起作用,请问是什么问题呢,要怎样解决,求助
最佳答案
评论() 相关
后面还有条评论,点击查看>>