disable Refresh button on IE,firefox,chrome Browser Using Javascript


<body id="MyBody" onkeydown="return showKeyCode(event)">

function showKeyCode(e) {
   // debugger;
    var keycode;
    if (window.event)
        keycode = window.event.keyCode;
    else if (e)
        keycode = e.which;

    // Mozilla firefox
    if ($.browser.mozilla) {
        if (keycode == 116 || (e.ctrlKey && keycode == 82)) {
            if (e.preventDefault) {
                e.preventDefault();
                e.stopPropagation();
            }
        }
    }
    // IE
    else if ($.browser.msie) {
        if (keycode == 116 || (window.event.ctrlKey && keycode == 82)) {
            window.event.returnValue = false;
            window.event.keyCode = 0;
            window.status = "Refresh is disabled";
        }
    }
    else {
        switch (e.keyCode) {

            case 116: // 'F5'
                event.returnValue = false;
                event.keyCode = 0;
                window.status = "Refresh is disabled";
                break;

        }
    }
}

Comments

  1. what is "jqcc"? is it related to jquery?

    ReplyDelete
    Replies
    1. instead of giving $ symble I given jqcc

      Delete
  2. Vinod the code which you have provided is not working for me. Is there any othere solution.

    ReplyDelete
  3. instead of using jqcc u can use $

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. it's not a good way waste other's time for hit your page

    ReplyDelete
  6. Please let me how may I have offended you "Anonymous"

    ReplyDelete
  7. will this work for refresh button as well? or just f5. thanks in advance.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. not working with refresh button .. I need this solution really

    ReplyDelete
  10. Can you tell me what error your facing send error screen short

    ReplyDelete
  11. Refresh button from browser is not working --Rohit

    ReplyDelete
  12. did u get browser refresh button solution

    ReplyDelete
  13. its only work for f5 button on keyboard but i want to disable refresh button on the browser window plz help me..

    ReplyDelete

Post a Comment