日期:2014-05-16 浏览次数:20360 次
1、在本地安装MSCOMMSetup原始.exe,下载地址为: http://download.csdn.net/detail/zxy838279821/4522994
目的是为了在本地注册MSCOMM32.OCX控件。
2、注册好了之后
先做个测试JSP,代码如下:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var CalendarWebControl = new atCalendarControl();
function prints(){
alert(printport);
}
function init(){
//document.all.printport.CommPort = "3";
// var object1=document.getElementById("printport");
// object1.PortOpen = true;
document.all.printport.PortOpen=true;
}
function doPrint(printmsg){
document.all.printport.Output = printmsg;
}
function pageEnd(){
document.all.printport.PortOpen = false;
}
</script>
</head>
<body onload='init();' onunload='pageEnd();'>
<p><object id="printport" classid="clsid:648A5600-2C6E-101B-82B6-000000000014" codebase="MCSCOMM32.cab" >
<param name="CommPort" value="3">
<param name="DTREnable" value="1">
<param name="Handshaking" value="0">
<param name="InBufferSize" value="1024">
<param name="InputLen" value="0">
<param name="NullDiscard" value="0">
<param name="OutBufferSize" value="512">
<param name="ParityReplace" value="63">
<param name="RThreshold" value="0">
<param name="RTSEnable" value="0">
<param name="BaudRate" value="9600">
<param name="ParitySetting" value="0">
<param name="DataBits" value="8">
<param name="StopBits" value="0">
<param name="SThreshold" value="0">
<param name="EOFEnable" value="0">
<param name="InputMode" value="0">
</object></p>
<p><input type="button" value="Print" name="B1" onclick=prints();'></p>
</body >
</html>
同时将MCSCOMM32.cab放到与JSP同级目录下去。MCSCOMM32.cab的下载地址:
http://download.csdn.net/detail/zxy838279821/4523005
当JS弹框为3,那么说明控件加载成功,程序已经可以向端口发数据了