Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

listen back button event listner

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
  }
}
Comment

back button event listener javascript

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

PREVIOUS NEXT
Code Example
Javascript :: javascript get image width and height 
Javascript :: nested for loops javascript 
Javascript :: javascript sql 
Javascript :: Prevent Double Submit with JavaScript 
Javascript :: npm auth0-react 
Javascript :: get elements by class is not working 
Javascript :: how to add css in js 
Javascript :: datatables get all rows 
Javascript :: create react app cmd 
Javascript :: react native change app name 
Javascript :: get ascii value of char javascript 
Javascript :: select2 find option by value 
Javascript :: jquery selector exists 
Javascript :: document onload 
Javascript :: remove all symbols javascript 
Javascript :: creating a class in angular 
Javascript :: how to get a record in dynamodb nodejs 
Javascript :: using map in useeffect 
Javascript :: javascript string includes substring 
Javascript :: vue v-on:click 
Javascript :: nodejs file exists 
Javascript :: upload multiple images cloudinary 
Javascript :: react-phone-number-input retur message in react hook form 
Javascript :: node js starting template 
Javascript :: flatlist onrefresh react native 
Javascript :: jqurey text contains selector 
Javascript :: latin science words 
Javascript :: javascript element in array 
Javascript :: js for in 10 
Javascript :: react font-awesome 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =