Reputation: 11
My application has multiple pages and it is inside another application as an iFrame. I want to redirect the user to home page if the browser is refreshed, but stay on the same page if he/she navigates to some other place in the parent application and comes back to my application.
I've tried using the PerformanceNavigationTiming interface and navigation type. It returns "reload" only in the parent application when the user reloads the page. Inside iFrame, it returns "navigate" as the navigation type.
var performance = window.performance.getEntriesByType("navigation");
if(String(performance[0].type) === "reload"){
//do redirection.
}
I want the navigation type to be reload inside the iframe.
Upvotes: 0
Views: 680
Reputation: 415
I'm afraid your iframe is not of the same origin.
Adapt your CORS (https://en.wikipedia.org/wiki/Same-origin_policy#Cross-Origin_Resource_Sharing )
Of course, there are other ways for cross document communication ( https://benohead.com/cross-document-communication-with-iframes/ )
Upvotes: 1