如题:身份证阅读器(读卡器)谷歌Chrome和火狐Firefox浏览器端网页开发接口控件分享,这个SDK开发包兼容支持谷歌Chrome浏览器和火狐Firefox浏览器,仅PC端使用,Android和iOS端浏览器不支持使用。
测试版本:
谷歌Chrome:58.0.3029.96
火狐Firefox:54.0.1
360安全浏览器:8.1.1.258
Internet Explorer:IE11
支持型号:华旭J15S、华旭J10-X
正在开发中型号:华视CVR-100U,神思SS628-100U、神盾ICR-100U、新中新DKQ-A16D,精伦IDR210、普天等;
以下贴出身份证阅读器谷歌和火狐浏览器控件部分代码,如需要完整版,请下载或联系我,QQ:313826379
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style>td {background-color:#eeeeee}input {width:430px;}.butt {width:150px; height:30px}.title {padding-left:10px; width:130px}</style> </head> <!-- <object class width=0 height=0"></object> --> <object TYPE="application/hxgc-device.j10" width=0 height=0></object><body> <table width="750px" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#FFFFFF"><tr><td colspan="3" align="center"><input type="button" name="OpenReader" value="打开设备" onClick="openReader();"><input type="button" name="startReadCard" value="读二代证" onClick="startReadCard();"><input type="button" name="CloseReader" value="关闭设备" onClick="closeReader();"><input type="button" name="Clear" value="清空信息" onClick="clearText();"></td></tr> <tr> <td >照片保存路径:</td> <td colspan="2"><input type="text" name="text_path" value=""> 注:路径结尾需添加"" </td></tr> <tr> <td >姓名:</td> <td width="430px"><input type="text" name="text_name" value="" readonly > </td> <td rowspan="5" align="center"><img name="Photo" /></td></tr><tr> <td >性别:</td> <td><input type="text" name="text_sex" value="" readonly > </td></tr><tr> <td >民族:</td> <td><input type="text" name="text_nation" value="" readonly > </td></tr><tr> <td >出生:</td> <td><input type="text" name="text_birthday" value="" readonly > </td></tr><tr> <td >地址:</td> <td><input type="text" name="text_address" value="" readonly > </td></tr><tr> <td >身份证号:</td> <td colspan="2"><input type="text" name="text_idNum" value="" readonly > </td></tr><tr> <td >签发机关:</td> <td colspan="2"><input type="text" name="text_dept" value="" readonly > </td></tr><tr> <td >开始期限:</td> <td colspan="2"><input type="text" name="text_effDate" value="" readonly > </td> </tr> <tr> <td >结束期限:</td><td colspan="2"><input type="text" name="text_expDate" value="" readonly ></td> </tr> <tr> <td >返回数据:</td> <td colspan="2"><textarea rows="10" name="text_result" cols="70" readonly></textarea></td> </tr> </table><script type="text/javascript" > var socket;var sendFlag=0;var PhotoPath = "C:";var PhotoName = "";document.getElementById("text_path").value = PhotoPath;function clearText(){PhotoPath = document.all("text_path").value;document.getElementById("text_name").value = "";document.getElementById("text_sex").value = "";document.getElementById("text_nation").value = "";document.getElementById("text_birthday").value = "";document.getElementById("text_address").value = "";document.getElementById("text_idNum").value = "";document.getElementById("text_dept").value = "";document.getElementById("text_effDate").value = "";document.getElementById("text_expDate").value = "";document.getElementById("text_result").value = "";document.getElementById("PhotoID").src = "";}function openReader() {var host = "";socket = new WebSocket(host);try {socket.onopen = function (msg) {openReaderStart(); //连接设备};socket.onerror = function(){};socket.onmessage = function (msg) {if (typeof msg.data == "string") {var msgM=msg.data+"";if(sendFlag==1){if(msgM[0]==0){resultMsg("错误:设备连接失败,"+msgM);}else if(msgM.indexOf("-1") >=0){resultMsg("该设备不支持谷歌");}else{resultMsg("设备已连接.");}}else if(sendFlag==2){if(msgM.indexOf("1") >=0){//resultMsg("身份证已放");getCardID();}else{resultMsg("请放身份证");}}else if(sendFlag==3&&!(msgM.indexOf("name") >=0)&& !(msgM[0].indexOf("1") >=0)){if(msgM[0]==0){resultMsg("读取身份证ID失败");}else{resultMsg("身份证ID:"+msgM);readIDCard();}}else if(sendFlag==4){if(msgM[0] == "0"){resultMsg("读取身份证信息失败:"+msgM);}else{//获得身份信息document.getElementById("text_name").value = msgM.match(/name(S*)name/)[1]; //姓名 document.getElementById("text_sex").value = msgM.match(/sex(S*)sex/)[1]; //性别 document.getElementById("text_nation").value = msgM.match(/nation(S*)nation/)[1]; //民族 document.getElementById("text_birthday").value = msgM.match(/birthDate(S*)birthDate/)[1]; //出生日期 document.getElementById("text_address").value = msgM.match(/address(S*)address/)[1]; //地址 document.getElementById("text_idNum").value = msgM.match(/IDCode(S*)IDCode/)[1]; //身份证号 document.getElementById("text_dept").value = msgM.match(/issuingAuthority(S*)issuingAuthority/)[1]; //签发机关 document.getElementById("text_effDate").value = msgM.match(/beginPeriodOfValidity(S*)beginPeriodOfValidity/)[1]; //有效日期起始 document.getElementById("text_expDate").value = msgM.match(/endPeriodOfValidity(S*)endPeriodOfValidity/)[1]; //有效日期截止saveJpgPhoto(msgM.match(/name(S*)name/)[1] + "_" + msgM.match(/IDCode(S*)IDCode/)[1]);}}else if(sendFlag==5){if(msgM.indexOf("1") >=0){resultMsg("保存JPG照片成功,路径 = " + PhotoPath + PhotoName + ".webp");saveBmpPhoto();}else{resultMsg("错误:保存JPG照片失败," + msgM + ".");}}else if(sendFlag==6){document.all("PhotoID").src = "file:///"+ PhotoPath + PhotoName + ".webp";if(msgM.indexOf("1") >=0){resultMsg("保存BMP照片成功,路径 = " + PhotoPath + PhotoName + ".bmp");}else{resultMsg("错误:保存BMP照片失败," + msgM + ".");}}else if(sendFlag==7){closeSocket();if(msgM.indexOf("1") >=0){resultMsg("关闭设备成功");}else{resultMsg("错误:关闭设备失败,"+msgM);}}}else{alert("连接异常,请检查是否成功安装华旭J15S驱动!");}};}catch (ex) {alert("连接异常,请检查是否成功安装华旭J15S驱动!");}}function resultMsg(msg) { document.getElementById("text_result").value += "" + msg;}</script> </body> </html>