How to shield system hotkeys in B/S Mode
Hbzxf (Hao)
Http://www.cnblogs.com/hbzxf/
I often develop B/S-mode software systems. I found that when I access the homepage of the main system, I often open a window without a toolbar or menu bar, the first is to provide users with a relatively wide visual and operational space, and once again avoid the negative consequences of user misoperations. My buddy is 'missing root string' (is the name really cool) I wrote a function and basically shielded some common function hotkeys. Let's take a look at how it was written.
Public void hideallfunction (page)
{
If (! Page. isstartupscriptregistered ("msghideallfunction "))
{
String clientscript = @ "<script language = JavaScript>
Function keydown (){
If (window. event. altkey) & (window. event. keycode = 37) | (window. event. keycode = 39) // mask Alt + direction keys ↓ // mask Alt + direction keys →
{
Event. returnvalue = false;
}
If (event. keycode = 116) // block the F5 refresh key
{
Event. keycode = 0;
Event. returnvalue = false;
}
If (event. ctrlkey) & (event. keycode = 78) // block Ctrl + n
{
Event. returnvalue = false;
}
If (event. shiftkey) & (event. keycode = 121) // block SHIFT + F10
{
Event. returnvalue = false;
}
If (event. keycode = 122) // block F11
{
Event. keycode = 0;
Event. returnvalue = false;
}
}
Function nocontextmenu ()
{
Event. cancelbubble = true
Event. returnvalue = false;
Return false;
}
Document. onkeydown = keydown;
Document. oncontextmenu = nocontextmenu;
</SCRIPT> ";
Page. registerstartupscript ("msghideallfunction", clientscript );
}
}