<MCE: Script Type = "text/JavaScript"> <! -- <Br/> function URL (URL) {<br/> url = URL | "http://blog.csdn.net/xxd851116"; <br/> This. url = URL. tostring (); <br/>}</P> <p> URL. prototype. getvalue = function (key) {<br/> If (this. url = NULL) return; <br/> If (Key = NULL) return; <br/> var key_values = This. URL. split ("? ") [1]. split ("&"); <br/> for (VAR I = 0; I <key_values.length; I ++) <br/>{< br/> var key_value = key_values [I]. split ("="); <br/> If (Key = key_value [0]) <br/>{< br/> return key_value [1]; <br/>}</P> <p> var url = "http://www.google.cn/search? Hl = ZH-CN & newwindow = 1 & Q = % E7 % AC % 91% E7 % 9A % 84% E8 % 87% Aa % E7 % 84% B6 & meta = & AQ = F & OQ = "; <br/> var url = new URL (URL); <br/> document. writeln ("Hl =" + URL. getvalue ("Hl") + "; <br/>"); <br/> document. writeln ("q =" + URL. getvalue ("Q") + "; <br/>"); <br/> // --> </MCE: SCRIPT>
Test results:
Hl = ZH-CN;
Q = % E7 % AC % 91% E7 % 9A % 84% E8 % 87% Aa % E7 % 84% B6;