mercredi 16 janvier 2019

Is there any way to detect the pressing of back button with vanilla JS?

I used this piece of code to detect the pressing of back button.

    if(performance.navigation.type === 2) {
                console.log("Back button detected, reloading page");
                location.reload(true);
    }

But according to MDN this has been deprecated. Are there any alternatives to use? I don't want to use any libraries like jquery.




Aucun commentaire:

Enregistrer un commentaire