Stringobject.split (separator,howmany)
Parameters |
Description |
Separator |
Necessary. 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. |
1 //Get the parameters in the URL 2 GetParam (); 3 function GetParam () {4 C1 = Window.location.href.split ("?") [1]; GetID5 id = c1.split ("&") [1].split ("=") [1];//Get the value of ID 6 id = id.lastindexof ("#")! =-1? Id.split ("#") [0]: ID; 7 Toolsceneid = C1.split ("&") [0].split ("=") [1];//Get the value of ID 8 }
The split () method splits the specified string by a specified delimiter, which splits into an array of strings and returns such as: string str = "AA.BB.CC.DD"; string[] Strarray = str. Split ('. '); The results obtained strarray the value of string[]{"AA", "BB", "CC", "DD"} where "AA", "BB", "CC", "DD" is the array of elements that make up arrays strarray each element corresponds to an index value, Just like in a table in a database each row of data records has its own index ID, the index value of the array element is counted from 0, that is, the index value of the first element is 0, followed by 1 we can use the index value of the array to take the value of the array element corresponding to the position, for example, we want to take the first element "Then we can write: string aa = Strarray[0]; here split ('. ') [1] is an abbreviated form, take it apart to see the reality is to first use split ('. ') method to use the string "." Cut to form a string array and then remove the value of the second element in the resulting array by index [1]
The split () method of the address URL is used;