<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>71街 &#187; url</title>
	<atom:link href="http://www.71j.cn/archives/tag/url/feed" rel="self" type="application/rss+xml" />
	<link>http://www.71j.cn</link>
	<description>杜工的技术博客</description>
	<lastBuildDate>Fri, 16 Dec 2011 03:52:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>操作页面刷新后，数据不能及时更新</title>
		<link>http://www.71j.cn/archives/37</link>
		<comments>http://www.71j.cn/archives/37#comments</comments>
		<pubDate>Tue, 01 Sep 2009 10:15:38 +0000</pubDate>
		<dc:creator>杜工</dc:creator>
				<category><![CDATA[感悟]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[刷新]]></category>
		<category><![CDATA[跳转]]></category>

		<guid isPermaLink="false">http://71j.cn/?p=37</guid>
		<description><![CDATA[众所周知，刷新页面可以直接在html的head标签中使用如下代码： &#60;meta http-equiv=&#34;refresh&#34; content=&#34;1; URL=http://www.71j.cn&#34;&#62; 其中content中的数字1表示等待是时间(秒) 也可以使用php发送头消... ]]></description>
			<content:encoded><![CDATA[<p>众所周知，刷新页面可以直接在html的head标签中使用如下代码：</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;refresh&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1; URL=http://www.71j.cn&quot;</span>&gt;</span></pre></div></div>

<p>其中content中的数字1表示等待是时间(秒)</p>
<p>也可以使用php发送头消息：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;location:http://71j.cn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>甚至可以使用js中window.location.reload()方法，但是我们在开发过程中发现，因为浏览器或者CDN等带有的缓存机制会使页面刷新后，数据得不到刷新。</p>
<p>解决办法如下：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> autorefresh<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> s<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&amp;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> href<span style="color: #339933;">=</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>href.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;t=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>href.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> s<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #339933;">;</span>
window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #339933;">+=</span>s<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;t=&quot;</span><span style="color: #339933;">+</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> href.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/t=[0-9]+/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;t=&quot;</span><span style="color: #339933;">+</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这样给url加上时间戳，可以有效解决本问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.71j.cn/archives/37/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>使用javascript从url获取参数值</title>
		<link>http://www.71j.cn/archives/33</link>
		<comments>http://www.71j.cn/archives/33#comments</comments>
		<pubDate>Tue, 01 Sep 2009 10:04:07 +0000</pubDate>
		<dc:creator>杜工</dc:creator>
				<category><![CDATA[感悟]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://71j.cn/?p=33</guid>
		<description><![CDATA[随着Ajax的泛滥，有时需要我们从url获取变量进行用户交互，本函数提供了获取方法： function getQuery&#40;name&#41; &#123; var reg = new RegExp&#40;&#34;(^&#124;&#38;)&#34;+ name +&#34;=([^&#38;]*)(&#38;&#124;$)&#34;&#41;; va... ]]></description>
			<content:encoded><![CDATA[<p>随着Ajax的泛滥，有时需要我们从url获取变量进行用户交互，本函数提供了获取方法：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getQuery<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> reg <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;(^|&amp;)&quot;</span><span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;=([^&amp;]*)(&amp;|$)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>reg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> unescape<span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>如需要从下面地址中获取id的值：</p>
<p>http://71j.cn/a.php?a=my&#038;id=7&#038;m=1</p>
<p>只需要在当前页面调用getQuery(“id”)即可。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.71j.cn/archives/33/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

