dunno if this is the right forum but what the hey...
does anyone know of a way to prevent the user refreshing a page?
cheers
| SitePoint Sponsor |

dunno if this is the right forum but what the hey...
does anyone know of a way to prevent the user refreshing a page?
cheers





if you hit f5 the keycode returned is 116 so just do something likePHP Code:<script type="text/javascript">
function getKeycode(e)
{
alert(event.keyCode)
}
document.onkeydown = getKeycode
</script>
this
PHP Code:<script type="text/javascript">
function getKeycode(e)
{
if (event.keyCode ==116) return false;
}
document.onkeydown = getKeycode
</script>





btw i recommend against doing this, as it will cause aggrevation to users by doing this.





Andrew:
The majority of users DON'T refresh using f5 - they use the button above.
I'd suggest something around the onbeforeUnload event.
Flawless
---=| If you're going to buy a pet - get a Shetland Giraffe |=---





thx flawless for picking up on that, you must of noticed i'm still half asleep.

onbeforeUnload... just looked it up.Originally posted by Flawless_koder
I'd suggest something around the onbeforeUnload event.
Flawless
i don't see how that can prevent a refresh.... it just warns people when they're about to close their browsers (isn't it?)
Also it only works in IE.
About blocking the F5... i agree with Flawless most people use the big refresh button in the toolbar.
Basically i want to prevent some form data that t being sent from the previous page from being sent again.
any suggestions?
cheers





i would use sessions and when the user submits something, just check whether the session is registered etc, and use an if statement to do one thing or the other. What server sie language are you using if you have one available?

Andrew,
I am using php as my serverside language.... but the page i want to stop being refreshed is already in a "members-only" section which uses sessions...
The session is registered when the user logs in...
i didn't think having a session running would prevent you from refreshing?? (i could be wrong tho)
cheers
Bookmarks