“Posłuchaj Listera zdarzeń Back Button” Kod odpowiedzi

Posłuchaj Listera zdarzeń Back Button

window.history.pushState({page: 1}, "", "");

window.onpopstate = function(event) {

  // "event" object seems to contain value only when the back button is clicked
  // and if the pop state event fires due to clicks on a button
  // or a link it comes up as "undefined" 

  if(event){
    // Code to handle back button or prevent from navigation
  }
  else{
    // Continue user action through link or button
  }
}
Clever Chamois

JavaScript Stenccript Butt Button

function goBack() {
    window.location.hash = window.location.lasthash[window.location.lasthash.length-1];
 	window.location.lasthash.pop();
}
Undefined

Odpowiedzi podobne do “Posłuchaj Listera zdarzeń Back Button”

Pytania podobne do “Posłuchaj Listera zdarzeń Back Button”

Więcej pokrewnych odpowiedzi na “Posłuchaj Listera zdarzeń Back Button” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu