I want to clear the session storage only on page refresh but not on the browser back button click , or forward click want to implement this using angularjs/javascript
i am saving data in sessionstorage on click of back button so just i want to clear the same data on click of browser refresh button but it should not clear for back
i have tried
if (performance.navigation.type == 1) {
$window.sessionStorage.clear();
// clearing the sessionstorage data
}
// but this one is clearing after clicking 2 times on refresh button
if (performance.navigation.type == 0) {
$window.sessionStorage.clear();
// clearing the sessionstorage data
}
// this one is clearing for back button as well ,
// tried onbeforeunload, onpopstate as well its not working its clearing for back button too
// please let me know how to implement this one, thanks in advance
// no jquery please