1. 程式人生 > >js 遮蔽 瀏覽器(IE和FireFox)的 重新整理功能

js 遮蔽 瀏覽器(IE和FireFox)的 重新整理功能

Java程式碼  收藏程式碼  
  
    document.onkeydown=function()    
    {    
      if ((window.event.keyCode==116)|| //遮蔽 F5    
          (window.event.keyCode==122)|| //遮蔽 F11    
          (window.event.shiftKey && window.event.keyCode==121) //shift+F10    
         )    
         {     
              window.event.keyCode=0;    
              window.event.returnValue=false;    
         }     
      if ((window.event.altKey)&&(window.event.keyCode==115))    
         {     
             //遮蔽Alt+F4    
             window.showModelessDialog("aboutlank","","dialogWidth:1px;dialogheight:1px");    
             return false;    
         }      
    }    

 
二,js遮蔽瀏覽器右鍵功能  
Java程式碼  收藏程式碼  
  
    if (window.Event)     
    document.captureEvents(Event.MOUSEUP);     
    function nocontextmenu()    
    {     
     event.cancelBubble = true     
     event.returnValue = false;     
     return false;     
    }     
    function norightclick(e){     
     if (window.Event){     
      if (e.which == 2 || e.which == 3)     
      return false;     
     }     
     else     
      if (event.button == 2 || event.button == 3){     
       event.cancelBubble = true     
       event.returnValue = false;     
       return false;     
      }     
    }     
    document.oncontextmenu = nocontextmenu; // for IE5+     
    document.onmousedown = norightclick; // for all others