Right-click a single JS page to prohibit the menu-to prevent the use of website information from being stolen
<SCRIPT type = "text/JavaScript">
Function Block (oevent ){
If (window. Event)
Oevent = Window. event;
If (oevent. Button = 2)
Alert ("right-click unavailable ");
}
Document. onmousedown = block;
</SCRIPT>
Prohibit Copying on webpages is mainly implemented by JavaScript.
<Body oncontextmenu = "Return false" onselectstart = "Return false"
Ondragstart = "Return false" onbeforecopy = "Return false" oncopy = Document. selection. Empty () onselect = Document. selection. Empty ()>
-----------------------------------------------
Prevents duplicate JS
-----------------------------------------------
<Script language = javascript1.2>
Function disableselect (e ){
Return false}
Function reenable () {return true
}
File: // If ie4 +
Document. onselectstart = new function ("Return false ")
File: // If ns6
If (window. Sidebar ){
Document. onmousedown = disableselect
Document. onclick = reenable
}
</SCRIPT>
<Script language = JavaScript type = text/JavaScript>
<! --
Function mm_reloadpage (init) {// reloads the window if nav4 resized
If (init = true) with (Navigator) {If (appname = "Netscape") & (parseint (appversion) = 4 )){
Document. mm_pgw = innerwidth; document. mm_pgh = innerheight; onresize = mm_reloadpage ;}}
Else if (innerwidth! = Document. mm_pgw | innerheight! = Document. mm_pgh) location. Reload ();
}
Mm_reloadpage (true );
// -->
</SCRIPT>
-------------------------------------------------------
Prevents the downloaded JS
-------------------------------------------------------
<NoScript> <IFRAME src = ""> </iframe> </NoScript>
--------------------------------------------------------
Below is the JavaScript code to prevent right-click:
--------------------------------------------------------
<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>
<Title> disable CSS selection and copying </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style>
Body {
-Moz-user-select: none;
Hutia: expression (this. onselectstart = function () {return (false )});
}
</Style>
</Head>
<Body>
Here is the webpage content. Can you copy it?
</Body>
</Html>
Application instance:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> JS control page </title>
<Script language = "JavaScript" type = "text/JavaScript">
// Prohibit users from using emails (hide the right-click menu)
Document. oncontextmenu = function forbidrightkey (){
Window. event. returnvalue = false;
}
// Prohibit users from using emails (prompt users to disable right-click)
Function Block (){
VaR oevent;
If (window. Event)
Oevent = Window. event;
If (oevent. Button = 2)
Alert ("right-click unavailable ");
}
Document. onmousedown = block;
// When you press altf4, the system prompts you to close the window.
Function altf4 (){
If (window. event. altkey & window. event. keycode = 115 ){
Window. Close ();
}
}
// Alt left mouse button composition shortcut key selected text box content call method <body onkeydown = "altf4 ();">
Function gettxtselect (eventcontrol ){
If (eventcontrol. altkey ){
Document. getelementbyid ("txt1"). Select ();
}
}
Function cleartxtbyinput (){
Document. getelementbyid ("txtcontent"). value = "";
}
Function filltxtbyinput (){
Document. getelementbyid ("txtcontent"). value = "Enter search criteria ";
}
// Disable several keys on the keyboard to call onkeydown = "forbidkeys ();"
Function forbidkeys (){
VaR content = Window. event. keycode;
If (content >=65 & content <= 68 ){
Window. event. returnvalue = false;
} Else {
Window. Alert (content );
}
}
// Prohibit the copying of webpage content <body oncopy = "forbidcopy ();">
Function forbidcopy (){
Window. event. returnvalue = false;
Window. clipboardData. setdata ("text ","");
Alert ("prohibit copying webpage content! ");
}
// Set the copy content to append the URL of the website
Function setcopycontent (){
Window. event. returnvalue = false;
VaR content = Document. Title + "/R/N ";
Content + = Document. getelementbyid ("txt1"). Value + "/R/N ";
Content + = "this resource comes from" + this. Location. href;
Window. clipboardData. setdata ('text', content );
Alert ("Copied successfully, paste it on your QQ/MSN and recommend it to your friends ");
}
// Do not refresh F5 or Ctrl + F5
Function forbidfreshpage (){
If (window. event. ctrlkey & window. event. keycode = 116) | window. event. keycode = 116 ){
Window. event. keycode = 0;
Window. event. returnvalue = false;
}
}
Document. onkeydown = forbidfreshpage;
// Shield JS errors
Function killerrors (){
Return true;
}
Window. onerror = killerrors;
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Input id = "txt1" type = "text" value = "Hello world! "Onclick =" gettxtselect (event) "/>
<Input type = "button" value = "copy the value in the text box" onclick = "setcopycontent ();"/>
<Input id = "txtcontent" value = "input Search Condition" style = "color: Aqua" onclick = "cleartxtbyinput ();" onblur = "filltxtbyinput ();"/>
<P> content </P>
</Div>
</Form>
</Body>
</Html>