Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I disable browser refresh in my webapp?

I want to disable refresh on my website. Is there any way to disable F5, Ctrl-R, or reload in a webpage?

like image 418
kiran Avatar asked Apr 19 '11 05:04

kiran


2 Answers

window.onbeforeunload = function () {return false;}

This disables leaving the page unless the user confirms, not only refresh, so you'll have to code this yourself to get it to work.

You never said what you were doing with it so I left it at that.

like image 170
Wesley Murch Avatar answered Oct 23 '22 10:10

Wesley Murch


No, there is no way to disable it.

If you are trying to avoid the "Do you want to submit this action again?" dialog, use Post/Redirect/Get.

like image 39
alex Avatar answered Oct 23 '22 09:10

alex