Items need to prohibit the screen, copy, print requirements, copy, print may be a little easier to do a lot of online scripts bowed down all. But how to stop the screen grip. Printscreen is a special key, it is a key without keycode, so onkeydown becomes useless. But another way of thinking can be better, we start from the paste plate to take the curve of salvation strategy. The code is as follows:
<script language= "JavaScript" >
Window.setinterval ("Clipboarddata.setdata" (' Text ', ') ', 100);
</script>
The above code clears the pasteboard operation every 100 milliseconds. The script begins to execute automatically when the page is loaded. But there is a drawback, no matter how the Web page is minimized or how as long as the window open all of our computer copy operation can not be done (the script has been emptying the pasteboard), in a sense is to achieve the desired effect, but some poor: (.
We know that all controls have onfocus and onblur events, and window windows are no exception. By taking advantage of these two events, we stop execution only if the current window is active and the vacuuming operation is performed. The code is as follows:
<script language= "JavaScript" >
var interval
Window.onfocus=function () {Interval=window.setinterval ("clipboarddata.setdata (' text ', ')", 100);}
Window.onblur=function () {window.clearinterval (interval);}
</script>
This will be a perfect solution to this problem. However, this method is of no use to the screen-cutting program which does not put the screen contents into the pasting board.
The latest test practice found that the method of using onfocus and onblur events is also unsatisfactory, and when the focus points to other controls within the program page (even a table), window loses focus and triggers the onblur event to stop the empty pasteboard command. Do you need to traverse all the controls for their onfocus and onblur binding events. Some confusion and disappointment.
Another window.onfocus is only the document's onfocus, if the focus is in the Address bar or the menu and other places onfocus will also fail.
Only in this text record their half a day to study JS experience.
Disable printing Simply put the following style code into the program (the printed page content will be blank):
<style> @media print{body{display:none}}</style>
No copy, select, right-click menu:
<script language=javascript>
function Click () {
return false;}
function Click1 () {if (event.button==2) {return false;}}
function CtrlKeyDown () {
if (Event.keycode==67&&event.ctrlkey)
{
Clipboarddata.setdata (' text ', ');
return false;
}
}
Document.onkeydown=ctrlkeydown;
Document.onselectstart=click;
Document.onmousedown=click1;
</script>
<noscript><iframe src=*.html></iframe></noscript>
<script language=javascript>
<!--
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
--></script>
The above code runs normally in the IE6.0 environment.
This article comes from: Script House (www.jb51.net) Detailed source reference: http://www.jb51.net/article/13610.htm
No copying and PRSCRN scratching
<script language=javascript>
function Nocopy ()
{
Alert ("Sorry, in order to protect the rights of authors, this site article does not allow copying." /n/n If you have special needs, please contact with this site. ");
Event.returnvalue=false;
}
</script>
<script>
function Stop () {
return false;
}
Document.oncontextmenu=stop;
</script>
<script language= "JavaScript" >
<!--
Shielding Printscreen
function Testclip () {
try {
if (Clipboarddata.getdata ("Text") | | Clipboarddata.getdata ("HTML") | | Clipboarddata.getdata ("URL"))//Detect system memory;
{
Memory is reserved if null;//is not an image
}
}
catch (e) {
Clipboarddata.setdata ("Text", "")//Empty memory
}
SetTimeout ("Testclip ()", 500)
}
The page loads the boot zone;
Testclip ()/Keep the Clipboard empty
-->
</script>
</HEAD>
<body bgcolor= #FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 oncopy= "nocopy ()" >
Oh
</BODY>