Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  23] [ 6]  / answers: 1 / hits: 15829  / 6 Years ago, tue, december 4, 2018, 12:00:00

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?


More From » html

 Answers
34

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.


[#52982] Thursday, November 29, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
johnathanhakeems

Total Points: 487
Total Questions: 129
Total Answers: 100

Location: Fiji
Member since Fri, Nov 13, 2020
4 Years ago
;