how to disable refresh button for browser in

Posted on 2011-05-12
Last Modified: 2012-05-11
Hi experts,

I want to block refresh button for browser .
i am using following javascript ,it works for me ,but it is disabling only F5. Please help

if (document.all){
document.onkeydown = function (){
var key_f5 = 116; // 116 = F5

if (key_f5==event.keyCode){
event.keyCode = 27;

return false;
Question by:gpinfotech
    LVL 39

    Expert Comment

    by:Pratima Pharande
    private bool _refreshState;
     private bool _isRefresh;
     protected override void LoadViewState(object savedState)
         object[] AllStates = savedState;
         _refreshState = bool.Parse(AllStates(1));
         _isRefresh = _refreshState == Session("__ISREFRESH");
     protected override object SaveViewState()
         Session("__ISREFRESH") = _refreshState;
         object[] AllStates = new object[3];
         AllStates(0) = base.SaveViewState;
         AllStates(1) = !(_refreshState);
         return AllStates;

    Open in new window

    LVL 14

    Assisted Solution

    The  Post-Redirect-Get pattern solves some of the problems related to page refreshing, mainly, reposting data. see here for details: and here for sampe:

    This will not Block the refresh, but it ensures that the user does not post data repeatedly. (Im not sure why you want to block refresh, Im assuming you want to avoid reposting :-) )
    LVL 16

    Accepted Solution


    using javascript you can disable the refresh button.

    try the below script in youe page.

    <Script language="javascript">
    function disableRefresh(evt)
    	var evt = (evt) ? evt : ((event) ? event : null);
    	var node = ( ? : ((evt.srcElement) ? evt.srcElement : null);
    		return false

    Open in new window

    Hope this may help you.

    Happy Programming.
    LVL 21

    Expert Comment

    by:Alpesh Patel
    Please write JS to block the key F5 in keypress or keydown event.
    Also hide the REfresh button using javascript.

    Author Comment

    Thanks alot
    LVL 19

    Expert Comment

    by:Amandeep Singh Bhullar
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now