I have read several StackOverflow answers about refreshing and/or reloading a page and how to determine.
Check if page gets reloaded or refreshed in JavaScript
and
Check if page gets reloaded or refreshed in JavaScript
in particular. Both of these questions have answers that appear to answer the question, how to determine when a page is refreshed or reloaded.
The problem is that the referenced PerformanceNavigation API appears to be deprecated and the New PerformanceNavigationTiming API looks like it is still not ready for production use.
I have tried using the old interface and the new interface. The OLD PerformanceNavigation works in Chrome, Firefox, and Edge.
The NEW PerformanceNavigationTiming does NOT seem to work in any of these browsers.
Here is the code is used from 1 of the questions I referenced.
if (window.PerformanceNavigation) {
console.info("window.performance works fine on this browser");
}
if (window.PerformanceNavigationTiming) {
console.info("window.performance works fine on this browser");
}
if (window.performance.navigation.type == "reload" || window.performance.navigation.type == 1) {
console.info( "This page is reloaded" );
} else {
console.info( "This page is not reloaded");
// console.info( "Value of Type is: " + window.PerformanceNavigationTiming.type());
}
if (window.PerformanceNavigationTiming.type == "reload" || window.PerformanceNavigationTiming.type == 1) {
console.info( "This page is reloaded" );
} else {
console.info( "This page is not reloaded");
// console.info( "Value of Type is: " + window.PerformanceNavigationTiming.type());
}
I really don't want to use deprecated API's for obvious reasons.
But I see no way around dealing with this problem.
Hoping for a really simple way to deal with this.
So, my questions are:
- Isn't the New Interface supposed to work when the old one is deprecated?
What did I do wrong trying to use the New Interface if it does work. I admit it could be me and lack of experience.
Any simple examples you can provide are appreciated.