<div class="codetitle"> <span><a style="CURSOR: pointer" data="74285" class="copybut" id="copybut74285" onclick="doCopy('code74285')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code74285"> <br><script><br> function goto_url(url){<br> var new_url = "http://shop.usteel.com/index.php?app=list_release";<br> var d_date = getParameter("date",url);<br> if(d_date != '' ){<br> new_url = "&" d_date;<br> }<br> var species = getParameter("species",url);<br> if(species != ''){<br> new_url = "&" species;<br> }<br><br> window.open(new_url);<br><br> }<br> // JavaScript Get the specified parameter and its corresponding value <br> Function GetParameter (Parastr, URL) <br> {<br> varress = "" "" "; <br> // Get all parameter list data <br> Var Str = "&" url.split ("?") [1]; <br> var Paraname = Parastr "="; <br> // Determine whether the parameters to be obtained are <br> if (str. indexOf("&" paraName)!=-1) <br> str.substring(str.indexOf(paraName), str.length).indexOf("&")!=-1) <br> var TmpStr=str.substring(str.indexOf(paraName ),str.length; "&" )-TmpStr.indexOf(paraName)); 🎜> result=str.substring(str.indexOf(paraName),str.length); } }<br> 🎜>The example below is complete and tested<br><br><br> </div> <br>Copy code<br><div class="codetitle"><span> The code is as follows:<a style="CURSOR: pointer" data="65999" class="copybut" id="copybut65999" onclick="doCopy('code65999')"><div class="codebody" id="code65999"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <br> <html xmlns="http://www.w3.org/1999/xhtml"> <br> <head> <br> <meta http-equiv="Content-Type" content ="text/html; charset=gb2312" /> <br> <title>javascript gets URL parameters and parameter values</title> <!-- <BR> var url = "http://www.baidu.com/?age=25&k=1&site=asp&abc=123;" <BR><BR> //javascript gets the specified parameters and their corresponding Value <br> function getParameter(paraStr, url) <br> { <BR> var result = ""; <BR> //Get all parameter list data in the URL <BR> var str = "&" url.split(" ?")[1]; <BR> var paraName = paraStr "="; <BR> //Determine whether the parameter to be obtained exists <BR> if(str.indexOf("&" paraName)!=-1) < { -1) <BR> //Intercept Characters from the beginning of the parameter to the nearest "&" occurrence <BR> result=TmpStr.substr(TmpStr.indexOf(paraName),TmpStr.indexOf("&")-TmpStr.indexOf(paraName)); <BR> } <BR> else <BR> <BR> else <BR> { <BR> result ="No such parameter"; <br><br> //Calling method: var variable name = getParameter("Parameter name to be obtained", URL address) <BR> var r = getParameter("age",url); <br><br> / /Test output, the result is: site=popasp <BR> alert(r); <BR> //You can use it based on the results obtained <BR> var pName = r.split("=")[0]; //Get Parameter name <BR> var pValue = r.split("=")[1]; //Get parameter value <br><br> //Test output: <BR> alert("Parameter name:" pName "nn" "Parameter value:" pValue); <br><br> //Other practical applications: <BR> //You can use the following methods to implement the functions you want to implement as needed; <BR> //var hostname = location.hostname ; //Get the current domain name (excluding http://) <BR> //var localurl = location.href; //Get the current complete URL address information (including http://, domain name, path, specific file and all Passing parameters) <BR> //var referurl = document.referrer; //Get the complete URL information of the previous page (including http://, domain name, path, specific file and all passing parameters) <br><br> / /--> <br> </div></a></span></div>