我想用这个控件打印我的jsp页面,可怎么也调不出控件来,请大家帮帮忙,smsx.cab我直接放到了WebRoot目录下,WebRoot/smsx.cab,版本号我是改的当前版本号smsx.inf文件里写的6,5,439,30,应该没有问题,请问还需要不需要其他操作?
这是我的jsp页面:
<head>
<title>a.jsp</title>
<object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="WebRoot/smsx.cab#Version=6,5,439,30"></object>
<script defer>
function setPrintBase(headerText,footerText,rootUrl) {
var header = (headerText==null||headerText=="")?'默认页眉':headerText;
var footer = (footerText==null||footerText=="")?'默认页角':footerText;
factory.printing.header = "&b"+header+"&b" ;
factory.printing.footer = "&b"+footer;
factory.printing.portrait = true;
factory.printing.leftMargin =10.00;
factory.printing.topMargin =10.00;
factory.printing.rightMargin =10.00;
factory.printing.bottomMargin =10.00;
}
</script>
</head>
<body bgcolor="#ffffff">
……………………省略……………………
</body>
还有ScriptXClientKit.msi这个控件我也装了,我把codebase="WebRoot/smsx.cab#Version=6,5,439,30",改成codebase="ScriptX.cab#Version=6,5,439,30"也不行。
这是我的jsp页面:
<head>
<title>a.jsp</title>
<object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="WebRoot/smsx.cab#Version=6,5,439,30"></object>
<script defer>
function setPrintBase(headerText,footerText,rootUrl) {
var header = (headerText==null||headerText=="")?'默认页眉':headerText;
var footer = (footerText==null||footerText=="")?'默认页角':footerText;
factory.printing.header = "&b"+header+"&b" ;
factory.printing.footer = "&b"+footer;
factory.printing.portrait = true;
factory.printing.leftMargin =10.00;
factory.printing.topMargin =10.00;
factory.printing.rightMargin =10.00;
factory.printing.bottomMargin =10.00;
}
</script>
</head>
<body bgcolor="#ffffff">
……………………省略……………………
</body>
还有ScriptXClientKit.msi这个控件我也装了,我把codebase="WebRoot/smsx.cab#Version=6,5,439,30",改成codebase="ScriptX.cab#Version=6,5,439,30"也不行。
<center class="Noprint"><input type=button value="打印" onclick="factory.printing.Print(true)"> <input type=button value="页面设置" onclick="factory.printing.PageSetup()"> <input type=button value="打印预览" onclick="factory.printing.Preview()"> <input type="button" value="关闭" onclick="window.close();">
放在table里。
把script放在最前,按钮放中间,object放在最后,试试
<head>
<title>a.jsp </title>
<script defer>
function setPrintBase(headerText,footerText,rootUrl) {
var header = (headerText==null||headerText=="")?'默认页眉':headerText;
var footer = (footerText==null||footerText=="")?'默认页角':footerText;
factory.printing.header = "&b"+header+"&b" ;
factory.printing.footer = "&b"+footer;
factory.printing.portrait = true;
factory.printing.leftMargin =10.00;
factory.printing.topMargin =10.00;
factory.printing.rightMargin =10.00;
factory.printing.bottomMargin =10.00;
}
</script>
</head>
<body bgcolor="#ffffff">
<input type=button value="打印" onclick="factory.printing.Print(true)">
……………………省略……………………
<object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="WebRoot/smsx.cab#Version=6,5,439,30"> </object>
</body>
smsx.cab位置放正确。
应该就没什么问题了