Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: disabling control keys in Netscape


Message #1 by "Randolph, Priya" <priya.randolph@d...> on Fri, 6 Dec 2002 17:29:36 +0530
Hi,
This is Priya.
 
I need to disable the conrol keys like ^N, ^A, ^I etc in Netscape
It works in IE but not in netscape
 
I am able to trap the control key sequence but not DISABLE it :(
 
 
here is the script i use:
 
<script language="javascript">
  var IE=0, NS=0;
// Detect the browser
IE  = (-1 != navigator.appVersion.indexOf("MSIE")) ? 1 : 0;
NS  = ("Netscape" == navigator.appName) ? 1 : 0;
  
  var blnDOM = false, blnIE4 = false, blnNN4 = false; 
 
if (document.getElementById) blnDOM = true;
else if (document.layers) blnNN4 = true;
else if (document.all) blnIE4 = true;
  
  
if (blnNN4 || NS) document.captureEvents(Event.KEYDOWN)
document.onkeydown =keydowncheck
  
   function keydowncheck(e)
   {
   if (NS)
   {
    var NN4key = e.which;
    if (e.which ==  122)
    {
     e.which = 0;
     alert("disabled NS!");
     return false;
    }
    else
   if((NN4key == 78) || (NN4key == 104) || (NN4key == 65) || (NN4key == 87)
|| (NN4key == 69) || (NN4key == 72) || (NN4key == 66) || (NN4key == 73))
     {
     //e.which=0;
     alert("Disabled Control!");
     //e.returnValue = false;
     e.preventDefault()
     //document.onkeydown=new Function("return false") 
     return false;
     
     }
   
    
  } 
   
   if (blnDOM || blnIE4)
   {
    if (122 == event.keyCode)
    {
     event.keyCode = 0;
     alert("disabled!");
     return false;
    }
 
    else if(event.ctrlKey)
    {
     if((event.keyCode == 78) || (event.keyCode == 104) || (event.keyCode ==
65) || (event.keyCode == 87) || (event.keyCode == 69) || (event.keyCode ==
72) || (event.keyCode == 66) || (event.keyCode == 73))
     {
     alert("Disabled!");
      event.returnValue = false;
     }
      
    }
   }
    
   }
 
</script>

 
 
( i have attached the file)
Pls help me with the solution.
 
 
 
 
Regards,
 
Priya Randolph
Digital GlobalSoft Ltd. 
(A subsidiary of Hewlett-Packard Co., USA) 

'Digital Park' , Plot No. 39/40,Konappana Agrahara,
Electronic city, Phase 2,Hosur Road,Bangalore
India 
TEL   : 91-80-8528395/6/7/8 Extn 62112
Email:  <mailto:priya.randolph@d...> priya.randolph@d...
 


  Return to Index