How do I block a browsers reload button
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.
Thanks.
Web Development
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.
Thanks.
by jay eckles
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:
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.
Jay
This discussion is closed to new replies.
Sort by Trending