JS Get URL Pass parameters
Here is a JavaScript client solution that gets the URL with the questring parameter, which is equivalent to the $_get function of the ASP's request.querystring,php:
<script language= "JavaScript" >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;}</Script>
Then we get the corresponding parameter value by calling this function:
<script language= "JavaScript" > varnew Object (); = getrequest (); var parameter 1, parameter 2, parameter 3, parameter n; = request[' parameter 1 ']; = request[' parameter 2 ']; = request[' parameter 3 ']; = request[' parameter n ']; </Script>
This gets the URL string with the same name parameter two, the regular analysis method.
function getquerystring (name) { varnew RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I" ); var r = window.location.search.substr (1). Match (reg); if (r!=nullreturnreturnnull;} Alert (getquerystring ("parameter name 1")),alert (getquerystring ("parameter Name 2")), alert (GetQueryString (" Parameter Name 3 "));
additional parameters to get introduced://Sets or gets the file name or path specified by the object.
alert (window.location.pathname);//Set or get the entire URL as a string.
alert (window.location.href);//Set or get the port number associated with the URL.
alert (window.location.port);//Set or get the protocol portion of the URL.
alert (window.location.protocol);//Set or get the fragment behind the pound sign "#" in the href attribute.
alert (window.location.hash);//Set or get the hostname and port number of the location or URL.
alert (window.location.host);//Set or get the portion of the HREF attribute that follows the question mark.
alert (window.location.search);This article transferred from: http://www.cnblogs.com/gaojun/archive/2013/06/09/3129412.html
JS Get URL Pass parameters