[Javascript]
String. prototype. getParameter = function (key ){
Var re = new RegExp (key + '= ([^ &] *) (? :&)? ');
Return this. match (re) & this. match (re) [1];
};
Test code:
[Javascript]
<Script type = "text/javascript">
<! --
String. prototype. getParameter = function (key ){
Var re = new RegExp (key + '= ([^ &] *) (? :&)? ');
Return this. match (re) & this. match (re) [1];
}; Www.2cto.com
Var s = "http://www.baidu.com/index.html? X0 = 0 & x1 = 1 & x2 = 2 & x3 = 3 & x4 = http://www.google.com ";
Document. write (s. getParameter ('x0') + "<br/> ");
Document. write (s. getParameter ('x1 ') + "<br/> ");
Document. write (s. getParameter ('x2 ') + "<br/> ");
Document. write (s. getParameter ('x3') + "<br/> ");
Document. write (s. getParameter ('x4 ') + "<br/> ");
Document. write (s. getParameter ('undefined') + "<br/> ");
// -->
</Script>
Output:
0
1
2
3