0

i have a php application where users can apply for a bonus. but there is a confirmation page before the bonus redemption code runs. the issue is that in IE, if you hit f5 right after you click the continue button, the confirmation page refreshes while the bonus redemption code had already been triggered by the continue button and actually goes through. but because the user still sees the confirmation page, they would hit the continue button again and now they get an error cause they are already registered.

is there a way i can disable the f5 button using javascript? is this the best way to go about this? i have tried many scripts i found online to do this, but none of them achieves it. is there a better way i can go about this? perhaps from the application side?

any input will be appreciated.

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pritaeas
3

I'd avoid all manner of hijacking the browser's functionality. That's really a big no-no in my book. You could however have a 'do you really want to refresh' notice in js (confirmation box). SOmething like this:

<script>
  window.onbeforeunload = cexit;
  function cexit(){
    return "Do you really want to refresh this page - that will be VERY BAD!";
  }
</script>

If the user does refresh and that messes up your functionality, I suggest that it's your code that needs tweaking. You shouldn't put the onus of good behaviour onto the user. Code for all possibilities, without inconveniencing them. So, hijacking the browser shouldn't even figure in your rationale.

Edited by diafol

1

Agree with diafol, do not do this. It wouldn't matter anyway, because you can still refresh by clicking the browser button. If you do so anyway, don't forgot to disable CTRL+F5 and CTRL+R too.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.