Web Development

General discussion


How do I block a browsers reload button

By SN_Web_Designer ·
Can someone tell me if it's possible to block the reload button in a browser by using either PHP or Javascript? If so, how would I do it? I can't seem to find anything about this anywhere else.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

don't allow reload from server side

by Jay Eckles In reply to How do I block a browsers ...

You can't effectively block browser controls using either server or client side programming. The only thing I can think of that you could do is refuse to reload the page from the server side.

If you site is PHP, then each time a request is made for a page, check the HTTP_REFERER. If it is the same as the page you're processing, then don't respond as normal. Instead, send an error message, alternate content, or a skeleton page like below:
<body onLoad="window.history.go(-1);">
Please wait while you are returned to the page...
That would immediately return the user to the previous page, effectively negating the reload. Of course, the "go back" code will only work for clients with Javascript enabled.


Related Discussions

Related Forums