日期:2014-05-16  浏览次数:20316 次

JS调用MSCOMM32.OCX的例子未触发其中的时间!怎么调整?
JScript code
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title>
  <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>
</head>

<script id="clientEventHandlersJS" language="javascript" type="text/javascript">   
    
 
function MSComm1_OnComm()   
{   
  var len=0;   
  window.alert("happy");   
  if(MSComm1.CommEvent==1)//如果是发送事件   
  {   
  window.alert("ok");//这句正常,说明发送成功了   
  }   
  else if(MSComm1.CommEvent==2)//如果是接收事件   
  {   
  //window.alert(MSComm1.CommEvent);  
  window.alert(MSComm1.Input);//   
  //documentdocument.form1.txtReceive.value=document.form1.txtReceive.value + MSComm1.Input;   
  }   
   
  return false;   
}   
    
</script>

<script language="javascript" for="MSComm1" event="OnComm">   

  MSComm1_OnComm()   
   
</script>

<script language="JavaScript" type="text/JavaScript">

  //打开端口并发送命令程序
  function OpenPort() {
  debugger;
  if (MSComm1.PortOpen == false) {
  MSComm1.PortOpen = true;
  MSComm1.Output = "R"; //发送命令   
  }
  else {
  window.alert("已经开始接收数据!");
  }
  }   

</script>

<body>
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZGG1hdTnKQNeruvlo/lg73qyBHUU" />
</div>


  <div>
  <input type="submit" name="Submit" value="提交" onclick="OpenPort()" />
  <input type="text" name="txtReceive" value="" />
  </div>
  </form>
</body>
</html>
一直只会执行这个已经开始接收数据

------解决方案--------------------
不会,帮你顶一下