JavaScript-Referenzhandbuch für Chinesisch
/ JavaScript Window History
JavaScript Window History
window.history 對(duì)象包含瀏覽器的歷史。
Window History
window.history對(duì)象在編寫(xiě)時(shí)可不使用 window 這個(gè)前綴。
為了保護(hù)用戶(hù)隱私,對(duì) JavaScript 訪問(wèn)該對(duì)象的方法做出了限制。
一些方法:
history.back() - 與在瀏覽器點(diǎn)擊后退按鈕相同
history.forward() - 與在瀏覽器中點(diǎn)擊按鈕向前相同
Window History Back
history.back() 方法加載歷史列表中的前一個(gè) URL。
這與在瀏覽器中點(diǎn)擊后退按鈕是相同的:
實(shí)例
<html> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="Back" onclick="goBack()"> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
Window History Forward
history forward() 方法加載歷史列表中的下一個(gè) URL。
這與在瀏覽器中點(diǎn)擊前進(jìn)按鈕是相同的:
實(shí)例
<html> <head> <script> function goForward() { window.history.forward() } </script> </head> <body> <input type="button" value="Forward" onclick="goForward()"> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例