Common Webpage Design Code

Source: Internet
Author: User
1. Prohibit page body content from being selected
<Body oncontextmenu = "Return false" ondragstart = "Return false" onselectstart = "Return false" onselect = "document. selection. empty () "oncopy =" document. selection. empty () "onbeforecopy =" Return
False "onmouseup =" document. selection. Empty () ">

2. Remove the image toolbar that automatically appears in IE6 and set the galleryimg attribute to false or no.


3. When you click an empty link, the page is often reset to the top.
Code "Javascript: void (null)" replaces the original "#" mark

4. How to prevent others from placing your webpage in the framework
<Script language = "JavaScript"> <! -- If (self! = Top) --> </SCRIPT>

5. Regularly refresh the page
<Meta http-equiv = "refresh" content = "seconds">

6. Switch the page to a new address on a regular basis
<Meta http-equiv = "refresh" content = "seconds; url = URL">

7. Close the window. This will not prompt you to close it directly:
Add the following code to the <body> area:
<Object ID = closes type = "application/X-oleobject" classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close">
</Object>
<Script language = "JavaScript"> function shutwin () </SCRIPT>
<A href = "javascript: shutwin ();"> close this window </a>
Sometimes it's hard to write Program The code is copied by others, so it will be hard to understand. This is a trivial matter, but if Source code There are some content that you don't want others to know, such as passwords and actions. Once these are used, the consequences are sometimes unimaginable. Web page encryption is the problem we need to solve now. Next, I will introduce some simple preventive methods based on my experience in creating web pages.
1. Right-click prohibited
As you can see, you will surely think that many people have introduced this trick, and there are also many methods to crack it. But here I want to talk about another method, and I tried a lot of methods that could not be cracked. The details are as follows:
<HTML>
<Head>
<SCRIPT>
Function stop (){
Alert ("Can I crack it? ");
Return false;
}
Document. oncontextmenu = stop;
</SCRIPT>
<Boyd> you can right-click the key on the left of Shift + F10 and right CTRL to try it! Check whether the problem can be solved. ^ _ ^ </Body>

Let's try it and see if it can be cracked! You can use alert ("can you try to crack it? "); This sentence is removed, so that when you right-click, there will be no response, as if there is no right-click function.

2. Forbidden to view source code
We have disabled the right-click menu, but the source code can also be seen in the "source file" under the "View" menu. Here we will solve this problem:
In fact, you only need to use a webpage with the <frame> </frame> mark to achieve the goal.
<Frameset>
<Frame src = "the URL of the file you want to keep confidential">
</Frameset>
In this way, when someone uses "View" the "source file", the above Code is displayed, and your real file is escaped.

3. Save the ban
The above two steps show that your source code is safe, but don't forget that others can save your page and analyze it slowly. But don't worry. Let's solve this problem.
Add the following code to the webpage you want to keep confidential:
<NoScript> <IFRAME src = "/*. htm"> </iframe> </NoScript>

4. Completely shield the right-click method. <Body oncontextmenu = "Return false">

---------------------------------------------------------------------------
Script Language = JavaScript>
// Double-click the page to automatically scroll the screen and click it to stop.
VaR currentpos, timer;
Function initialize ()
{Timer = setinterval ("scrollwindow ()", 16 );}
Function SC (){
Clearinterval (timer );
}
Function scrollwindow ()
{Currentpos = Document. Body. scrolltop;
Window. Scroll (0, ++ currentpos );
If (currentpos! = Document. Body. scrolltop)
SC ();
}
Document. onmousedown = SC
Document. ondblclick = initialize

</SCRIPT>

____________________________________________________________________

<! -- "Save the ban as" Start --->

<NoScript>
<IFRAME src = "/*. htm"> </iframe>
</NoScript>

<! -- "Save the ban as" end --->

<Script language = "JavaScript">

// Set a script error to continue running

Function killerror ()
{
Return false;

}

Window. onerror = killerror;

</SCRIPT>
------------------------------------------------------------------


Practical Tips for creating web pages
1. oncontextmenu = "window. event. returnvalue = false"
Will completely shield the right mouse button

<Table border oncontextmenu = return (false)> <TD> NO </table>
Available for table

2. <body onselectstart = "Return false">
Cancel selection and prevent Replication

3. onpaste = "Return false"
Do not paste

4. oncopy = "Return false;" oncut = "Return false ;"
Prevent Replication

5. <LINK rel = "shortcut icon" href = "favicon. ICO">
Replace the IE icon in front of the address bar

6. <LINK rel = "bookmark" href = "favicon. ICO">
Show your icons in favorites

7. <input style = "ime-mode: Disabled">
Disable Input Method

8. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frames.htm ";

// Frames.htm is the webpage
// --> </SCRIPT>

9. Prevent Frame
<Script language = JavaScript> <! --
If (top. location! =

Self. Location) top. Location = self. location;
// --> </SCRIPT>

10. <NoScript> <IFRAME src = "/*. html>"; </iframe> </NoScript>
Webpages cannot be saved

11. <input type = button value = view webpage source code
Onclick = "window. Location = 'view-Source: '+

'Http: // www.csdn.net/'">

12. How to use ASP to check whether the visitor has used an agent?
<% If request. servervariables ("http_x_forwarded_for") <> ""

Then
Response. Write "<font color = # ff0000> you have passed the proxy server ,"&

_
"The real IP address is

"& Request. servervariables (" http_x_forwarded_for ")
End if
%>

13. Obtain the absolute position of the control

// Javascript
<Script language = "JavaScript">
Function getie (e ){
VaR T = E. offsettop;
VaR L = E. offsetleft;
While (E = E. offsetparent ){
T + = E. offsettop;
L + = E. offsetleft;
}
Alert ("Top =" + T + "nleft =" + l );
}
</SCRIPT>

// VBScript
<Script language = "VBScript"> <! --
Function getie ()
Dim t, L, A, B
Set a = Document. All. img1
T = Document. All. img1.offsettop
L = Document. All. img1.offsetleft
While a. tagname <> "body"
Set a = A. offsetparent
T = T + A. offsettop
L = L + A. offsetleft
Wend
Msgbox "Top =" & T & CHR (13) & "Left =" & L, 64, "Get control position"
End Function
--> </SCRIPT>

14. The cursor stops at the end of the text box.
<Script language = "JavaScript">
Function CC ()
{
VaR E = event. srcelement;
VaR r = E. createTextRange ();
R. movestart ('character ', E. value. Length );
R. Collapse (true );
R. Select ();
}
</SCRIPT>
<Input type = text name = text1 value = "123" onfocus = "CC ()">

15. determine the source of the previous page
ASP:
Request. servervariables ("http_referer ")

Javascript:
Document. referrer

16. Minimize, maximize, and close the window
<Object ID = HH1

Classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "minimize"> </Object>
<Object ID = HH2

Classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "maximize"> </Object>
<Object ID = hh3

Classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close"> </Object>

<Input type = button value = minimized onclick = hh1.click ()>
<Input type = button value = maximized onclick = hh2.click ()>
<Input type = button value = Disable onclick = hh3.click ()>
This example applies to IE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.