Javascript Simplest Detect Page Refresh Code
Simplest Reliable Way to Detect Page Refresh in Javascript via Function isPageRefresh()
Home
Short:
Try refreshing this page and then going to a different page and come back
THIS PAGE NOT REFRESHED (new visit)
function isPageRefresh() { if (!window.performance || !window.performance.getEntriesByType) { return false; } const entries = window.performance.getEntriesByType("navigation"); if (entries.length === 0) { return false; } const type = entries[0].type; // Check if the type is 'reload' return type === "reload"; }
source code home
S
H
A
R
E
Facebook
Twitter
LinkdIn
Reddit
Blogger
π Ώing
Email π§
π Multiple
Facebook
Twitter
Linkdin
Reddit
Blogger
Ping
Email
Share β