I used to determine if user had come by clicking the back button in the previous page using window.performance.navigation.type
like
if (window.performance.navigation.type === 2) {
window.location.reload()
}
I saw that this property has been deprecated and succeeded by Navigation Timing Level 2. How can I mimic the behavior of performance.navigation api by this?
I should preface this by saying that I am not JavaScript pro. This is my approach for utilizing Navigation Timing Level 2.
if (String(window.performance.getEntriesByType("navigation")[0].type) === "back_forward") {
window.location.reload()
}
window.performance.getEntriesByType("navigation")
returns a list of PerformanceEntry objects every mark set. If you haven't set any marks, this list contains a single object that has the navigation information for the window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With