Scenario 1:
The $_get function equivalent to the ASP's request.querystring,php:
functiongetrequest () {varurl = location.search;//gets the URL in the "?" String after the character varTherequest =NewObject (); if(Url.indexof ("?")! =-1) { varstr = URL.SUBSTR (1); STRs= Str.split ("&"); for(vari = 0; i < strs.length; i + +) {Therequest[strs[i].split ("=") [0]]= (Strs[i].split ("=") [1]); } } returntherequest;}varRequest =NewObject (); Request=getrequest ();varparameter 1, parameter 2, parameter 3, parameter n; parameter 1= request[' parameter 1 ']; parameter 2= request[' parameter 2 ']; parameter 3= request[' Parameter 3 ']; parameter n= request[' parameter n '];
Scenario 2:
Using regular expressions
function getquerystring (name) { varnew RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I" ); var r = window.location.search.substr (1). Match (reg); if (r!=nullreturnreturnnull;}
Easter eggs, get the current URL and other parameters:
Sets or gets the file name or path specified by the object.
alert (window.location.pathname);
Sets or gets the entire URL as a string.
Window.location.href
Sets or gets the port number associated with the URL.
Window.location.port
Sets or gets the protocol portion of the URL.
Window.location.protocol
Sets or gets the segment behind the pound sign "#" in the href attribute.
Window.location.hash
Set or get the hostname and port numbers for the location or URL.
Window.location.host
Sets or gets the portion of the HREF attribute that follows the question mark.
Window.location.search
JS Get URL Pass parameters