how to detect when I return to a page with java script

0

I have a problem with a report in which I include dates that are loaded into controls with a javascript function I call this in my document.ready so that I can set dates for today and then execute my search according to those dates up there all right, my problem comes when I select certain dates and I do my search I have the option to go to another page to see the details of some record my search but at the time of dare back I rerun the function java script of the dates and I removed the ones I selected earlier, do you know if there is a method that helps me detect when I'm backing or forwarding the page and can keep the data?

    
asked by Pily Bueno 30.01.2018 в 00:30
source

1 answer

0

try to save them in localStorage with this you save it locally even if you change pages or close the browser

localStorage.setItem("date1", "29/01/18");

var mydate= localStorage.getItem("date1");

When you no longer use the variable, delete it with localStorage.removeItem("date1");

    
answered by 30.01.2018 в 01:38