JavaScript วินดาว ประวัติ
วัตถุ window.history มีประวัติเว็บเบราซเรอร์
Window History
window.history
วัตถุนี้สามารถเขียนโดยไม่ใช้ window
เพื่อปกป้องความเป็นส่วนตัวของผู้ใช้งาน JavaScript มีการจำกัดในการเข้าถึงวัตถุนี้
วิธีต่างๆ:
- history.back() - คล้ายกับการกดปุ่มหลังหลังในเว็บเบราซเรอร์
- history.forward() - คล้ายกับการกดปุ่มหน้าต่อไปในเว็บเบราซเรอร์
Window History Back
history.back()
ʷбеǰURL
ͬǰеǰť
ʵ
ҳУǰť
<html> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="Back" onclick="goBack()"> </body> </html>
룺(ť):
Window History Forward
history forward()
ʷбеһURL
ͬǰеǰť
ʵ
ҳУǰǰť
<html> <head> <script> function goForward() { window.history.forward() } </script> </head> <body> <input type="button" value="Forward" onclick="goForward()"> </body> </html>
룺