Railway number reading, railway number
The previous article has introduced "test COM with IE", so we use an actual instance to use it.
Before that, we need to understand two Javascript Functions:
Converts a string to a character array.
string.split(",");
I. js part
We put all the methods in a RepoInfo object.
var RepoInfo = { };
1. Get the object
RepoInfo.getObj = function(objName) {return new ActiveXObject(objName);};
2. Get the Array
RepoInfo.getArray = function(str) {var ret = new Array(16);var string = str.replace(/\s/g, "");ret = string.split(",");return ret;};
3. decoding string (1) input string verification. If the string is empty, exit. (2) Empty the output box before each assignment. (3) execute the methods in COM to get the object without being empty.
RepoInfo.decode = function(string) {if (string == null) return;var obj = RepoInfo.getObj("repoInfo.LabelInfo");var edtView = document.getElementById("edtView");edtView.value = " ";var str = RepoInfo.getArray(string);if (obj != null)edtView.value = obj.getInfo(str);};
Ii. html Section
1. Button events
Obtain the string from the input box as the input parameter of the js method. Note: Use the two quotation marks together.
<Input type = "button" id = "btnOk" value = "execute data parsing" onClick = "RepoInfo. decode (document. getElementById ('edtdata'). value)"/>
2. Page Effects
Tag data:
Execution result:
3. Source Code (including js Code)
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Post:
There are only two formal railway vehicle number development institutions (institutes/enterprises) in China: yuanwanggu and Wick.
Reference Document (W3School ):
1. replace Method
2. RegExp object
3. split Method