<?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>reload &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/reload/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 02 Jul 2019 00:40:13 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>reload &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>JavaScript 重新整理頁面</title>
		<link>https://noter.tw/2297/javascript%e9%87%8d%e6%96%b0%e6%95%b4%e7%90%86%e9%a0%81%e9%9d%a2/</link>
					<comments>https://noter.tw/2297/javascript%e9%87%8d%e6%96%b0%e6%95%b4%e7%90%86%e9%a0%81%e9%9d%a2/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Wed, 19 Sep 2012 12:00:30 +0000</pubDate>
				<category><![CDATA[網頁前端]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[refresh]]></category>
		<category><![CDATA[reload]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=2297</guid>

					<description><![CDATA[<p>突然發現蛙齋的JavaScript分類中的文章只有三篇，但對於小蛙的工作來說JavaScript也算是重要的一環，還是記錄一下以後查找方便。這篇主要是記錄網路上查到的一些關於「重新整理頁面」的資料。 &#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2297/javascript%e9%87%8d%e6%96%b0%e6%95%b4%e7%90%86%e9%a0%81%e9%9d%a2/" data-wpel-link="internal">JavaScript 重新整理頁面</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>突然發現蛙齋的JavaScript分類中的文章只有三篇，但對於小蛙的工作來說JavaScript也算是重要的一環，還是記錄一下以後查找方便。這篇主要是記錄網路上查到的一些關於「重新整理頁面」的資料。<br />
<span id="more-2297"></span><br />
在《<strong><a href="http://blog.yam.com/htshboy/article/12692684" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">Javascript刷新頁面的幾種方法 @ 玲瓏天空<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>》一開頭就直接寫明了重新整理頁面的方法，整篇文章也很細心的列出一些常用的情況。</p>
<blockquote><p><strong>Javascript刷新頁面的幾種方法：</strong><br />
1&nbsp;&nbsp; history.go(0)<br />
2&nbsp;&nbsp; location.reload()<br />
3&nbsp;&nbsp; location=location<br />
4&nbsp;&nbsp; location.assign(location)<br />
5&nbsp;&nbsp; document.execCommand(&#8216;Refresh&#8217;)<br />
6&nbsp;&nbsp;&nbsp;window.navigate(location)<br />
7&nbsp;&nbsp; location.replace(location)<br />
8&nbsp;&nbsp; document.URL=location.href</p></blockquote>
<p>上面的八種方法小蛙並沒有一個一個測試，只找了符合自己使用情況的方法，例如：小蛙有一個編輯頁面上有多選欄位、單選欄位、文字欄位 &#8230; 等，這些資料原本就已經有值了(從資料庫撈出來)，而有一個重填按鈕，點了之後將頁面設定為尚未編輯前的資料，也就是如果原本多選欄位選了五個，編輯時把全部取消勾選，後來發現想要恢復原始設定點了重填按鈕，希望可以回復原始資料(跟新增時的重填不同，新增時的重填只要清空即可)，好吧！這裡可能寫的有點複雜，總而言之最偷懶的方法就是讓頁面變成第一次載入時的狀況，於是小蛙直接用JavaScript的重新整理。<br />
常看到的重新整理大概是location.reload();，但做了之後發現，原本被修改過的欄位並不會回復到原始狀況，就是說上面取消的五個多選欄位，並不會恢復成勾選狀態，之後試了location=location可以達到這個要求。有點像是F5(重新整理)跟Ctrl+F5(強制重新整理)的差別，location.reload();跟小蛙直接點F5一樣結果，而location=location的結果跟Ctrl+F5相同。<br />
後來小蛙在《<strong><a href="http://topic.csdn.net/u/20071025/10/d7f7e90e-3c8f-4b61-824f-2146d411f49c.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">请问如何区别window.location.Reload()和window.location.href=window.location.href;<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>》這個討論串中找到了為什麼location.reload();不能的答案</p>
<blockquote><p>flyerwing :<br />
定义和用法<br />
reload() 方法用于重新加载当前文档。<br />
语法<br />
location.reload(force)说明<br />
如果该 方法没有规定参数，或者参数是 false，它就会用 HTTP 头 If-Modified-Since 来检测服务器上的文档是否已改变。如果文档已改变，reload() 会再次下载该文档。如果文档未改变，则该方法将从缓存中装载文档。这与用户单击浏览器的刷新按钮的效果是完全一样的。<br />
如果把该方法的参数设置为 true，那么无论文档的最后修改日期是什么，它都会绕过缓存，从服务器上重新下载该文档。这与用户在单击浏览器的刷新按钮时按住 Shift 健的效果是完全一样。<br />
好象是说:<br />
如果window.loacation.reload(true)==window.location.href=&#8221;xxx.xx&#8221;;</p></blockquote>
<p>馬上試了一下，果然把location.reload();改成location.reload(true);就可以了！</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2297/javascript%e9%87%8d%e6%96%b0%e6%95%b4%e7%90%86%e9%a0%81%e9%9d%a2/" data-wpel-link="internal">JavaScript 重新整理頁面</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/2297/javascript%e9%87%8d%e6%96%b0%e6%95%b4%e7%90%86%e9%a0%81%e9%9d%a2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
