I want to know if jquery or javascript can detect if the user has pressed the refresh button of their browser? If so can I see an example?
There is no way to detect if the user pressed refresh before the page refreshes, but you can use cookies to determine if the page refreshed once it loads the second time.
For example, each page could store the location.href
in a cookie, and if the last cookie equals the same location.href
of the current page, then the user most likely refreshed the page.