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.

Recommended Answers

All 3 Replies

Member Avatar


is there a way i can disable the f5 button using javascript?

Yes, you can disable f5

Here is a link to do that


I think this question is more in javascript than php. I think it's best to post this question there. This is all I can help you because I'm not familiar with javascript.

Member Avatar

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:

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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.