<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/get-urlparar-js/</link>
<title><![CDATA[用js获取url的参数值]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[前端开发]]></category>
<pubDate>Thu, 26 Aug 2010 04:04:56 +0000</pubDate> 
<guid>https://www.heckjj.com/get-urlparar-js/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 微软雅黑;">在用js获取url的参数值的时候有两种方法可寻，当然啦可能会有更好的方法。这里只介绍下这两种。<br/>一、字符串分割分析法。</span><br/><textarea name="code" class="js" rows="15" cols="100">
&nbsp;&nbsp;function GetQueryString(name)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var reg = new RegExp("(^&#124;&)" + name + "=([^&]*)(&&#124;$)","i");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var r = window.location.search.substr(1).match(reg);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (r!=null) return unescape(r[2]); return null;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;alert(GetQueryString("参数名1"));
&nbsp;&nbsp;&nbsp;&nbsp;alert(GetQueryString("参数名2"));
&nbsp;&nbsp;&nbsp;&nbsp;alert(GetQueryString("参数名3"));
</textarea><span style="font-family: 微软雅黑;"><br/>二、正则分析法。</span><br/><textarea name="code" class="js" rows="15" cols="100">
&nbsp;&nbsp;function GetRequest()
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var url = location.search; //获取url中"?"符后的字串
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var theRequest = new Object();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (url.indexOf("?") != -1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var str = url.substr(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strs = str.split("&");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(var i = 0; i < strs.length; i ++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return theRequest;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;var req = new Object();
&nbsp;&nbsp;&nbsp;&nbsp;req = GetRequest();&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;参数1 = req["参数1名称"];
&nbsp;&nbsp;&nbsp;&nbsp;参数2 = req["参数2名称"];
</textarea><br/>Tags - <a href="https://www.heckjj.com/tags/js/" rel="tag">js</a> , <a href="https://www.heckjj.com/tags/url/" rel="tag">url</a>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/get-urlparar-js/#blogcomment</link>
<title><![CDATA[[评论] 用js获取url的参数值]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/get-urlparar-js/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>