作用是用文件保存/读取WOW的密码保护卡上的数字,^_^,只能用IE看。 < html > < script language = " javascript " > function DataLoad() { var fileName = document.getElementById("fileName"); if (fileName.value == "") { alert("请选择数据文件。"); fileName.focus(); fileName.select(); return; } try { var fso = new ActiveXObject("Scripting.FileSystemObject"); var file = fso.OpenTextFile(fileName.value,1); var datas = file.ReadLine(); if (datas != "") { var array = datas.split(','); var item; for (var i = 0; i < array.length; i++) { item = array[i].split(':'); document.getElementById(item[0]).value = item[1]; } } file.close(); } catch (e) { alert(e.message); } } function DataSave() { var fileName = document.getElementById("fileName"); if (fileName.value == "") { alert("请选择数据文件。"); fileName.focus(); fileName.select(); return; } try { var fso = new ActiveXObject("Scripting.FileSystemObject"); var file = fso.OpenTextFile(fileName.value,2); var data = ""; var ctrl; var cid; for (var i = 1; i < 11; i++) { for (var j = 65; j < 73; j++) { cid = String.fromCharCode(j) + i.toString(); ctrl = document.getElementById(cid); if (Validate(cid,Trim(ctrl.value))) { data += ","; data += (cid + ":" + Trim(ctrl.value)); } else { ctrl.focus(); ctrl.select(); return; } } } file.WriteLine(data.substring(1)); file.close(); alert("数据已保存。"); } catch (e) { alert(e.message); } } function DataSearch() { var cid = document.getElementById("xAxes").value + document.getElementById("yAxes").value; var ctrl = document.getElementById(cid); if (ctrl.value != "") { document.getElementById("txtResult").value = ctrl.value; ctrl.focus(); ctrl.select(); } else { alert("请先载入数据文件。"); } } function Validate(cid,data) { if (data == "") { alert("位置 " + cid + " 没有输入数据。"); return false; } if (data.length > 2) { alert("位置 " + cid + " 最多输入2位整数。"); return false; } if (data.match(/^\d+$/) == null) { alert("位置 " + cid + " 只能输入整数。"); return false; } return true; } function ltrim(s) { return s.replace( /^\s*/, ""); } function rtrim(s) { return s.replace( /\s*$/, ""); } function Trim(s) { return rtrim(ltrim(s)); } </ script > < body > < div align = " center " > < h3 > 选择数据保存文件 </ h3 > < input type = " file " id = " fileName " size = 60 >< input type = " button " value = " 载入数据 " id = " btnLoad " onclick = " DataLoad(); " > </ div > < div align = " center " > < table width = " 80% " border = 1 > < tr > < td align = " center " width = " 300px " > < h3 > 密码保护卡数据 < h3 > < table > < tr > < td ></ td > < td align = " center " > A </ td > < td align = " center " > B </ td > < td align = " center " > C </ td > < td align = " center " > D </ td > < td align = " center " > E </ td > < td align = " center " > F </ td > < td align = " center " > G </ td > < td align = " center " > H </ td > </ tr > < tr > < td align = " center " > 1 </ td > < td align = " center " >< input type = " text " id = " A1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G1 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H1 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 2 </ td > < td align = " center " >< input type = " text " id = " A2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G2 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H2 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 3 </ td > < td align = " center " >< input type = " text " id = " A3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G3 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H3 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 4 </ td > < td align = " center " >< input type = " text " id = " A4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G4 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H4 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 5 </ td > < td align = " center " >< input type = " text " id = " A5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G5 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H5 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 6 </ td > < td align = " center " >< input type = " text " id = " A6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G6 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H6 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 7 </ td > < td align = " center " >< input type = " text " id = " A7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G7 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H7 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 8 </ td > < td align = " center " >< input type = " text " id = " A8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G8 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H8 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 9 </ td > < td align = " center " >< input type = " text " id = " A9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G9 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H9 " size = 2 ></ td > </ tr > < tr > < td align = " center " > 10 </ td > < td align = " center " >< input type = " text " id = " A10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " B10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " C10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " D10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " E10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " F10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " G10 " size = 2 ></ td > < td align = " center " >< input type = " text " id = " H10 " size = 2 ></ td > </ tr > < tr > < td align = " center " colspan = 8 > < input type = " button " value = " 保存数据 " id = " btnSave " onclick = " DataSave(); " > </ td > </ tr > </ table > </ td > < td align = " center " valign = " top " > < h3 > 查找数据 < h3 > < table > < tr > < td > 坐标: </ td > < td > < select id = " xAxes " > < option value = " A " > A </ option > < option value = " B " > B </ option > < option value = " C " > C </ option > < option value = " D " > D </ option > < option value = " E " > E </ option > < option value = " F " > F </ option > < option value = " G " > G </ option > < option value = " H " > H </ option > </ select > < select id = " yAxes " > < option value = " 1 " > 1 </ option > < option value = " 2 " > 2 </ option > < option value = " 3 " > 3 </ option > < option value = " 4 " > 4 </ option > < option value = " 5 " > 5 </ option > < option value = " 6 " > 6 </ option > < option value = " 7 " > 7 </ option > < option value = " 8 " > 8 </ option > < option value = " 9 " > 9 </ option > < option value = " 10 " > 10 </ option > </ select > </ td > < td colspan = 2 >< input type = " button " value = " 查找数据 " id = " btnSerch " onclick = " DataSearch(); " </ td > < td > 结果: </ td > < td > < input type = " text " value = "" id = " txtResult " size = 3 > </ td > </ tr > </ table > </ td > </ tr > </ table > </ div > </ body > </ html > 转载于:https://www.cnblogs.com/jxhwei/archive/2007/03/15/676396.html