DISABLE CTRL,ALT and BACK THROUGH JAVASCRIPT & DO YOUR ACTION ON BROWSER CLOSE BUTTON THROUGH JS !!!

Discussion in 'HTML / PHP / JavaScript / CSS' started by techexpert, Jul 19, 2008.

  1. Hi this is the code for how to disable CTRL,ALT and Back through JavaScript, you can disable thse keys through this code.
    and the code given below you use that for action on browser Close button through Java Script!!



    function disableKeys(e)
    {
    var ev=(!e)?window.event:e;//IE:Moz
    if(ev.keyCode==8)
    {
    return false;
    }
    if((ev.altKey==true)&amp;&amp;(ev.keyCode>=65) &amp;&amp; (ev.keyCode<=90))
    {
    return false;
    }
    // http://www.infysolutions.com

    if((ev.altKey==true)||(ev.ctrlKey==true))
    {
    return false;
    }
    }


    ******************************



    DO YOUR ACTION ON BROWSER CLOSE BUTTON THROUGH JAVASCRIPT

    window.onbeforeunload=function()
    {
    var keyCd = null;
    var altKy = false;
    var ctlKy = false;
    var shiftKy = false;
    keyCd = event.keyCode;
    altKy = event.altKey;
    ctlKy = event.ctlKey;
    shiftKy = event.shiftKey;
    if((window.event.clientX<0) || (window.event.clientY<0))
    {
    // Code for your action
    }
    else if ((altKy &amp;&amp; keyCd == 115) &amp;&amp; !ctlKy &amp;&amp; !shiftKy &amp;&amp; keyCd != 116)
    {
    // Code for your action
    }
    else if ((altKy &amp;&amp; keyCd == 70) &amp;&amp; !ctlKy &amp;&amp; !shiftKy &amp;&amp; keyCd != 116)
    {
    // Code for your action
    }
    }
    ----------------------------------

    Offshore Software Development

    Offshore Outsourcing Software Development

    Post Edited (techexpert) : 7/19/2008 10:23:15 AM GMT
     

Share This Page