The meaning of the object's prototype in JS:
Each object in JavaScript has the prototype property, and the prototype property of the object in JavaScript is interpreted as a reference to the object type prototype.
A.prototype = new B ();
Understanding prototype should not confuse it with inheritance. A's prototype is an example of B, and it's understandable that a will clone the methods and properties in B all over again. A can use the methods and properties of B. The emphasis here is on cloning, not inheritance. This can happen: the prototype of A is an instance of B, and the prototype of B is also an instance of a.
To set the class property of an element:
function SetClass () { var setclass = document.getElementById ("Project2"); = "on"; }
To set the connection page of a column iframe:
function SetUrl () { var setiframe = document.getElementById ("iframe"); = "project2.html"; }
The split () method is used to split a string into an array of strings.
Stringobject.split (Separator,howmany)
Separator: Required. A string or regular expression that splits stringobject from where specified by the parameter.
Howmany: Optional. This parameter specifies the maximum length of the returned array. If this parameter is set, the returned substring will not be more than the array specified by this parameter. If this argument is not set, the entire string is split, regardless of its length.
The match () method retrieves the specified value within a string, or finds a match for one or more regular expressions.
The method is similar to IndexOf () and lastIndexOf (), but it returns the specified value instead of the position of the string.
Stringobject.match (Searchvalue) stringobject.match (regexp)
Searchvalue: Required. Specifies the string value to retrieve.
RegExp: Required. A RegExp (regular expression) object that specifies the pattern to match. If the parameter is not a RegExp object, you need to first pass it to the RegExp constructor and convert it to a RegExp object.
Returns a string that is the specified value.
Use cookies to pass values:
Create cookies
To create a default syntax format:
Document.cookie = name + value;
Cases:
Document.cookie = "Cookiename=" + "Mod"
Note: It is not possible to have non-alphabetic or numeric characters, so it is a good choice to transcode them.
Escape () can encode a string:
var cookielist = "Firstname=" + "one" + "; Lastname= "+" "n" = Escape (cookielist);
Note: There are also two cookies defined here, which must be ";" when defining multiple cookies. Separated.
When reading a text string encoded with "Escape (text)", it must be decoded using "unescape (text)".
There are four properties in addition to "name":
Expires (set time), path (access directory), domain (multi-server access), secure (security transfer)
Expires: The default shutdown session will destroy the cookie and give it a time to specify.
var New = Escape ("Firstcookie=bon" + "; espires=" + Expdate.setdate (expdate.getdate () + 1));
Path: Setting a cookie can be accessed by other Web pages on the server, by default to pages in the same directory.
Make all pages in the files file directory or its subdirectories accessible:
Document.cookie = "Firstname=one" + ";p ath=/files";
If you want to allow cookies to be accessed by all pages on the server, use only one "/" representation.
Document.cookie = "Firstname=one" + ";p ath=/";
Domain: Used to share cookies across multiple servers within the same domain.
If you have 7 top-level domain identifiers (. com,. edu,. NET,. org,. gov,. a mil,. int) ends with only two dots in the string. Can:
Document.cookie = "Firstname=one" + ";d omain=.baidu.com";
If you end with a different identifier, the string requires three dots "." and includes a subdomain,
For example: End With "cn", "domain=. Subdomain. Domain. CN"
Document.cookie = "Firstname=one" + ";d omain=.ziyu.yu.cn";
Secure: Indicates that cookies can only be transmitted over a secure Internet connection and this property is usually ignored.
Document.cookie = "Firstname=one" + "; secure=true";
Read cookies:
You need to parse each cookie using the method of the string object, and if the cookie is encoded with escape (), it must be decoded with the unescape () function before parsing.
Here we use the String object method, including the IndexOf (), substring () method, to determine the location of the cookie's name and value to derive the corresponding value.
You can also use regular expressions to make judgments and take out value values.
Cases:
// set Cookies function Setcookie (name, value) { = name + "=" + Escape (value); } // Get Cookies function GetCookie (name) { varnew RegExp ("(^|)" + name + "= ([^;] *)(;|$)"); var arr = Document.cookie.match (reg); document.getElementById ("Text1"). Value = Arr[2];
}
HTML code:
<inputID= "we"type= "button"value= "Settings"onclick= ' Setcookie ("Coo0", "Zhizhi") '/> <BR/> <BR/> <inputID= "Button1"type= "button"value= "button"onclick= ' GetCookie ("coo0") '/> <inputID= "Text1"type= "text" />
20150803--JS Study notes (1)