把網路上流傳的刷新寫法整理如下,前半段是實測可用的版本。
<input type=button value=刷新 onclick="history.go(0)">
<input type=button value=刷新 onclick="location.reload()">
<input type=button value=刷新 onclick="location=location">
<input type=button value=刷新 onclick="window.navigate(location)">
<input type=button value=刷新 onclick="location.replace(location)">
以下三種流傳於各處,但實際該怎麼觸發、在哪些環境下有效,一直沒有明確說法,先原樣保留:
<input type=button value=刷新 onclick="document.execCommand('Refresh')">
<input type=button value=刷新 onclick="window.open('自身的檔名','_self')">
<input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>
其中 ExecWB 與 document.all 都帶有明顯的 IE 專屬痕跡,跨瀏覽器時不建議採用;若只求穩定,location.reload() 仍是最保险的選擇。