js頁面跳轉、頁面傳值、頁面刷新(筆記)方法整理

js頁面跳轉、頁面傳值、頁面刷新(筆記)方法整理

js頁面跳轉、頁面傳值、頁面刷新(筆記)方法整理


資料來源: https://ithelp.ithome.com.tw/articles/10190062

https://codertw.com/%E5%89%8D%E7%AB%AF%E9%96%8B%E7%99%BC/288732/


方案01:

1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)針對IE,firefox不支援
7 location.replace(location)

history.go(0):刷新本頁
history.go(-1):回到上一頁
history.go(-2):回到上一頁的上一頁

reload()跟history.go(0)相同

window.location與assign相同


方案02:

//按鈕式:
<INPUT name="pclog" type="button" value="GO" onClick="location.href='http://www.ddhbb.com/'">

//連結式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>

//直接跳轉式:
<script>window.location.href='http://www.ddhbb.com';</script>

//開新視窗:
<a href="javascript:" onClick="window.open('http://www.ddhbb.com/blog/guestbook.asp',",'height=500,width=611,scrollbars=yes,status=yes')">布丁足跡</a>

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *