1. Install mscommsetup .exe on the local machine to register the MSCOMM32.OCX control locally.
2. After registration
Run the following code to test JSP:
<Html>
<Head>
<Script language = "JavaScript" type = "text/JavaScript">
Var CalendarWebControl = new atCalendarControl ();
Function prints (){
Alert (printport );
}
Function init (){
// Document. all. printport. commp ORT = "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 = "comatrix Ort" 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>
When the JS bullet box is 3, it indicates that the control is successfully loaded and the program can send data to the port.