I filled out a form containing my full name and address. When I press βR, the page refreshes, but the form still contains the data that I filled out.
When I reload a webpage using the reload button in the upper left corner of Google Chrome, the form will be blank.
How can I detect this difference with JavaScript (or jQuery)?
I tried this:
$(window).on('load', function(){
localStorage.setItem('gForm_isDone', '{"0":false,"1":false,"2":false,"3":false,"4":false,"5":false,"6":false,"7":false,"8":false,"9":false,"10":false,"11":false}');
console.log('localStorage emptied');
console.log(localStorage.getItem('gForm_isDone'));
});
In my scenario, I want to clear localStorage, but only when the page reloads, not when refreshing.
source
share