Javascript web page full screen and prohibit all webpage buttons (domestic version)
Yang Yong, bjash@126.com
The following code is sourced from network collection. Here, we only modify and integrate some errors,
This code is suitable for making pages that require full screen and disabling special buttons! Normal input and multiple choice are not affected.
// Save this file as forbidden. js. When used: <script language = "JavaScript" src = "forbidden. js"> </SCRIPT>
// Disable Content Selection
Function document. onselectstart () {return false ;}
// Prohibit drag and drop of content
Function document. ondragstart () {return false ;}
// Disable context menu
Function document. oncontextmenu () {return false ;}
// Disable printing. Add the code in the style:
// @ Media Print {body {display: None}. In this way, the printed webpage is empty.
Function isfocus (eltid)
{// Determine whether an element gets the focus
// Alert (event. currenttarget. ID );
// Alert (document. activeelement. tagname );
If (document. activeelement. ID = eltid)
{// Alert ('get focal point ');
Return true;
}
Else {
// Alert ('unobtained focal point ');
Return false;
}
}//
Function isFullscreen ()
{If (window. screenLeft = 0 & amp; empty rows Doc ument. body. clientWidth = window. screen. width
&&#;Doc ument. body. offsetHeight = window. screen. height)
{// Location. href = "Help Page, set the IE parameter! ";
// Alert ('fullscreen ');
Return true;
}
Else
{// Alert ('non-fullscreen ');
Return false;
}
}
Function auto_submit ()
{
// Alert ('login ');
}
Window. onblur = auto_submit;
// The following Code enables full screen display
Function window. onload ()
{
// Hide the scroll bar
// Document. getelementsbytagname ('body') [0]. style. Overflow = 'sidd ';
// Document. getelementsbytagname ('body') [0]. Scroll = "no ";
Isfullscreen ();//***************
}
Function document. oncontextmenu () {event. returnvalue = false;} // right-click the screen
Function window. onhelp () {return false;} // block F1 help
// Mask some buttons
Function document. onkeydown ()
{
// Type of the object when the document. activeElement. type key is pressed: type Value
// Typeof (document. activeElement. type) = 'undefined') when you focus on the body, the type is undefined. Be sure to use typeof to judge !!!
// The name BODY, INPUT, and TEXTAREA of the document. activeElement. tagName label. The INPUT cannot distinguish between text and radio.
// Unblocking the back page: the Key activation object is blocked when a single button or multiple button or BODY is selected, while text and textarea are not blocked.
If (event. keyCode = 8 & (document. activeElement. type = 'Radio '|
Document. activeElement. type = 'check' | typeof (document. activeElement. type) = 'undefined '))
{Event. keyCode = 0; event. returnValue = false ;}
Else if (event. ctrlKey & event. keyCode = 82) {event. keyCode = 0; event. returnValue = false;} // shield Ctrl + R
Else if (event. keyCode = 116 | event. keyCode = 122) {event. keyCode = 0; event. cancelBubble = true; event. returnValue = false;} // block F5, F11, and prevent event bubbles
Else if (event. ctrlKey & event. keyCode = 78) event. returnValue = false; // block Ctrl + n
Else if (event. ctrlKey & event. keyCode = 67) event. returnValue = false; // block Ctrl + v
Else if (event. shiftKey & event. keyCode = 121) event. returnValue = false; // block shift + F10
Else if (window. event. srcelement. tagname = "A" & window. event. shiftkey) window. event. returnvalue = false; // block shift with the left mouse button to open a new page
Else if (window. event. altkey) & (window. event. keycode = 115) // mask Alt + F4
{Window. showmodelessdialog ("about: blank", "", "dialogwidth: 1px; dialogheight: 1px"); Return false ;}
Else if (window. event. altkey) & (window. event. keycode = 37) | (window. event. keycode = 39 )))
{// Block Alt + direction keys, → forward or backward webpage, but hold down the Alt key, it cannot be blocked
Event. returnvalue = false;
}
}