项目开发中遇到的实际问题,需要从浏览器读取串口数据。网上查了很多资料。比较靠谱的整理了一下。
需要下载一个ComAxCtrl.ocx控件,然后将控件注册一下即可。
<!Doctype html>
<html>
<head>
<title></title>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<style type="text/css">
body{
text-align: center;
font-size: 12px;
margin: 0px;
padding: 0px;
}
.clear{
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
.cssCenter{
margin-top: 0px;
margin-bottom: 0px;
margin-left: auto;
margin-right: auto;
}
</style>
<script type="text/javascript">
var ComAxCtrl=null;
/**
* 检测是否允许ActiveX控件运行
* @param true-允许ActiveX控件运行;false-不允许ActiveX控件运行
*/
function isActiveXEnabled() {
//xmlhttp对象
var kXmlHttp = null;
//如果是IE浏览器
if ($.browser.msie!=null && $.browser.msie == true) {
//微软IE支持的xmlhttp对象
var aVersionhs = ["MSXML2.XMLHttp.5.0",