首页 新闻 搜索 专区 学院

如何使用ActiveX把页面进行打印.我的代码为什么总是报JavaScript错

0
悬赏园豆:100 [待解决问题]

我也是看了别人的例子模仿了一下但是总是报错,希望高手来帮忙..

//main.htm


<

 <head>

  <title></title>

 </head>

<frameset rows="10%,90%" frameborder="0" border="0" frameSpacing="0">

<frame id="header" name="header" src="Header.htm" noresize scrolling="no">

<frame id="report" name="report" src="Default.aspx" noresize scrolling="auto">

 </frameset>

</html>

html>

//Header.htm
<html>

<head>

 <title>打印</title>

<script id="clientEventHandlersJS" type="text/javascript" language="javascript">

function btnPrint_onclick() {

//備份客戶打印機設置

var h = factory.printing.header;

var f = factory.printing.footer;

var t = factory.printing.topMargin;

var b = factory.printing.bottomMargin;

var l = factory.printing.leftMargin;

 var r = factory.printing.rightMargin;

 //設置頁眉腳上下左右邊距

factory.printing.header = "";

 factory.printing.footer = "";

 factory.printing.topMargin = "0";

 factory.printing.bottomMargin = "0";

 factory.printing.leftMargin = "0";

 factory.printing.rightMargin = "0";

 //打印

parent.report.focus();

 parent.report.print();

 //恢復原來的打印設置

factory.printing.header = h;

factory.printing.footer = f;

factory.printing.topMargin = t;

factory.printing.bottomMargin = b;

factory.printing.leftMargin = l;

factory.printing.rightMargin = r;

 }

 </script>

<OBJECT id="factory" style="DISPLAY: none" codeBase="http://localhost/WebApplication1/smsx.cab#VVersion=6,3,434,12" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>

</OBJECT>

</head>

<body bgColor="#9999cc">

<INPUT id="btnPrint" type="button" value="Print" name="Print" onclick="return btnPrint_onclick()">

</body>

</html>

 

 

每一次都报

 

factory.printing.header无效

级别:菜鸟的主页 级别:菜鸟 | 初学一级 | 园豆:100
提问于:2010-11-08 16:17
< >
分享
所有回答(1)
0

可以用捕捉一下异常看看,如果只是打印当前页面的话可以用window.print() 就可以了

如果是IE的话,还可以用WebBrowser控件

John29 | 园豆:825 (小虾三级) | 2010-12-06 13:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册