Objek History Window
- Previous Page Window Console
- Next Page Window Location
Objek History Window
Objek History mengandung URL yang diakses pengguna (dalam jendela browser).
Objek History adalah atribut objek window.
Objek History dapat diakses melalui cara berikut:
window.history
atau hanya history
:
Contoh
let length = window.history.length;
let length = history.length;
Atribut dan Metode Objek History
Atribut/Metode | Deskripsi |
---|---|
back() | Muat URL (halaman) sebelumnya di daftar sejarah. |
forward() | Muat URL (halaman) berikutnya di daftar sejarah. |
go() | Muat URL (halaman) tertentu dari daftar sejarah. |
length | Kembalikan jumlah URL (halaman) dalam daftar sejarah. |
Deskripsi Objek History
Objek History asalnya dirancang untuk menunjukkan sejarah pelayaran halaman. Tetapi karena alasan privasi, Objek History tidak lagi memungkinkan skrip mengakses URL yang telah diakses. Fungsi yang masih digunakan hanya back()、forward() and go() Method.
Example
The operation performed by the following line of code is the same as clicking the back button:
history.back()
The operation performed by the following line of code is the same as clicking the back button twice:
history.go(-2)
- Previous Page Window Console
- Next Page Window Location