Thursday, October 5, 2023
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  55] [ 2]  / answers: 1 / hits: 53074  / 15 Years ago, fri, april 10, 2009, 12:00:00

I want an event handler that fires when the user hits reload. Is onrefresh or onreload the correct handler to add to ? Also, will this even fire before or after onunload? Are there an browser inconsistencies? Thanks.


More From » javascript

 Answers
86

I don't think there are events called onrefresh or onreload. You can know when the page is unloading, but knowing why (i.e. where the user is going next) is outside JavaScript's security sandbox. The only way to know whether the page has been reloaded is to know where the user was on the last page request, which is also outside the scope of JavaScript. You can sometimes get that via document.referrer, but it relies on the browser's security settings to permit access to that information.


[#99721] Friday, April 3, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatumm

Total Points: 47
Total Questions: 92
Total Answers: 89

Location: Palau
Member since Tue, May 30, 2023
5 Months ago
tatumm questions
Wed, May 12, 21, 00:00, 2 Years ago
Wed, Feb 19, 20, 00:00, 4 Years ago
Tue, Jul 16, 19, 00:00, 4 Years ago
;