Browser Refresh

They have: 82 posts

Joined: Oct 2001

Is there any way to detect a browser refresh?

an OnRefresh() method ?

The reason is I have a page that submits data.
Once it submits I do not want them to refresh.
I want to redirect of they refresh.

Thanks,

Mike

Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Well, there's OnUnload and OnBeforeUnload (IE only). I don't think OnUnload will work in this case, and OnBeforeUnload is going to give you an annoying alert box that you can't get rid of.

Probably the simplest way is to have some sort of server-side variable (session/database/cookie) that you store a counter in, then if they try to submit the form again you do a response.redirect to another page.

PJ | Are we there yet?
pjboettcher.com

They have: 4 posts

Joined: Apr 2002

You can, if you're using php or another server side language, load a variable into the querystring and check for it. The first time the page is loaded, the variable, let's say "i" will not be there so auto refresh with i=1. But from now on, if you have i=1 the data will not be accepted.

What is your server side based on? PHP/ASP?

Artur
eBoundHost Support
Web Hosting: $9.95
Dedicated: $99.95

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.