Web Geçmişi API'si
Web Geçmişi API'si, windows.history nesnesine erişmek için kolay yöntemler sağlar.
window.history nesnesi, kullanıcı tarafından ziyaret edilen URL'leri (Web Siteleri) içerir.
Web Geçmişi API'si tüm tarayıcılarda desteklenir:
Yes | Yes | Yes | Yes | Yes |
Geçmişe geri() Yöntemi
back() yöntemi, windows.history listesinde önceki URL'yi yükler.
Tarayıcınızdaki "geri oku" tıklamakla aynıdır.
Örnek
<button onclick="myFunction()">Go Back</button>
<script>
function myFunction() {
window.history.back();
}
</script>
Geçmiş go() Yöntemi
go() yöntemi, geçmiş listesinden belirli bir URL yükler:
Örnek
<button onclick="myFunction()">Go Back 2 Pages</button>
<script>
function myFunction() {
window.history.go(-2);
}
</script>
Geçmiş Nesne Özellikleri
Property | Description |
---|---|
length | Returns the number of URLs in the history list |
Geçmiş Nesne Yöntemleri
Method | Description |
---|---|
back() | Loads the previous URL in the history list |
forward() | Loads the next URL in the history list |
go() | Loads a specific URL from the history list |