JavaScript serial port (through the vb's MSCOMM32.OCX control)

来源:互联网 发布:笨办法学python kindle 编辑:程序博客网 时间:2024/05/22 06:39

JavaScript serial port (through the vb's MSCOMM32.OCX control)


Tag: Web the development of, input, html, object, vb

My Computer is already installed vb environment, the main is that the MSCOMM32.OCX file already exists

<html> 
<head> 
<title> JavaScript serial port (through the vb's MSCOMM32.OCX controls) </ title> 

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript> 
<! - 
/ / Rewrite the the only event-handling code of the the mscomm control are 
function MSComm1_OnComm () 

var len = 0; 
/ / Window.alert ("Happy"); 
if (MSComm1.CommEvent == 1) / / If it is send events 

window.alert ("ok") ;/ / phrase normal, send the Description was successful 

else if (MSComm1.CommEvent == 2) / / If it is receive events 

/ / Window.alert (MSComm1.CommEvent) ;/ /! ' 
/ / Window.alert (MSComm1.Input) ;/ / 
document.form1.txtReceive.value = document.form1.txtReceive.value + MSComm1.Input; 


return false; 

/ / -> 
</ SCRIPT> 

<SCRIPT LANGUAGE=javascript FOR=MSComm1 EVENT=OnComm> 
<! - 
/ / MSComm1 controls per encountered OnComm event is on the call the MSComm1_OnComm () function 
MSComm1_OnComm () 
/ / -> 
</ SCRIPT> 


<script language="JavaScript" type="text/javascript"> 
<! - 
/ / Open the port and send the command procedures 
function OpenPort () 

if (MSComm1.PortOpen == false) 

MSComm1.PortOpen = true; 
MSComm1.Output = "R" ;/ / sending command 

else 

window.alert ("have already Start Receive an data if!"); 


-> 
</ Script> 

</ Head> 

<OBJECT CLASSID = "clsid: 648A5600-2C6E-101B-82B6-000000000014" id = MSComm1 codebase = "MSCOMM32.OCX" type = "application / x-oleobject" 
style = "LEFT: 54px; TOP: 14px"> 
<PARAM NAME="CommPort" VALUE="1"> 
<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="?"> 
<PARAM NAME="RThreshold" VALUE="1"> 
<PARAM NAME="RTSEnable" VALUE="1"> 
<PARAM NAME="SThreshold" VALUE="2"> 
<PARAM NAME="EOFEnable" VALUE="0"> 
<PARAM NAME="InputMode" VALUE="0"> 

<PARAM NAME="DataBits" VALUE="8"> 
<PARAM NAME="StopBits" VALUE="1"> 
<PARAM NAME="BaudRate" VALUE="9600"> 
<PARAM NAME="Settings" VALUE="9600,N,8,1"> 
</ OBJECT> 
<body> 

<form name="form1"> 
<input type="submit" name="Submit" value="" onClick="OpenPort()"> 
<input type="text" name="txtReceive" value=""> 
</ Form> 
</ Body> 
</ Html>