Solved

Detecting browser refresh

Posted on 2000-04-13
6
461 Views
Last Modified: 2008-02-01
Is there any way to detect if the user has pressed the refresh button on the browser? The reason why I'm asking this is I'm trying to prevent an ASP script from re-running when the user presses the Refresh button (I know it sounds stupid, but someone out there is likely to do it!)
0
Comment
Question by:iukpo
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
djbusychild earned 100 total points
ID: 2714246
well, the irony is that you want to detect browser refresh using javascript to prevent ASP from reexecuting?
what are you gonna do? write to the from javascript cookie or soemthing?

you can detect refresh by waiting for an onunload event. That event will also fire when the user leaves the page, but if you're only concern is to mark the page so that it won't reexecute, than it make perfect sense, since if the user goes somewhere else and comes back the page shouldn't refresh, right?
0
 

Expert Comment

by:chandlermcc
ID: 2714286
you could use a session object on the server side to track this sort of thing. the session wouldnt expire until the client closes the browser or it times out. refreshing the browser wouldnt effect the session
0
 

Expert Comment

by:chandlermcc
ID: 2714314
you could use a session object on the server side to track this sort of thing. the session wouldnt expire until the client closes the browser or it times out. refreshing the browser wouldnt effect the session
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:djbusychild
ID: 2714581
chandlermcc, imagine keeping all those in a session object on a website that has 100 pages and 10000 people visit the site and quit the browser without giving the site a chance to explicitly expire the session.... assume the integer stored in the session object is 4byes, that's 400 bytes per use who has seen 100 pages
and that's 4000000 bytes (or about 4MB)... don't you think that's a waste of memory?

the memory won't be able to be reclaimed for a while, either...

what you should rather do is tweak the page expiration so that the page will be loaded from cache rather than from the server
0
 

Expert Comment

by:chandlermcc
ID: 2714612
Yeah, that's why it was a comment and not an answer :) But I do agree with you. Funny, I've never heard anyone say good things about sessions...
0
 
LVL 5

Expert Comment

by:djbusychild
ID: 2714627
Actually, I think Sessions are awesome. It's just that it's not all that great to be used here. ;) It's cool to have it to store something small and if kept at a minimum. ^^;
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now