To keep people from seeing my Web page. Method Rollup for source code

Source: Internet
Author: User
Tags interface key return safe mode setcookie window domain access
Web page | source code

  1, add the following code to the <body></body> between Heml

<script language=javascript>
function Click () {if (event.button==2) {alert (' Don't you peek! ');}} Document.onmousedown=click
</SCRIPT>
.................................................................
  2, prohibit the view page source code

True to achieve the source code shielding simple. htm is impossible! To see the source code is no way to stop. You can download any file with Teleprot, which is equivalent to doing a mirrored web site, unless the server is securely set up and encrypted. Here are a few reference methods to make it impossible to use the right key when browsing my personal home page or to see the source program or source code.

1 Enter the code on the homepage:

<script language=javascript>
function Click () {
if (event.button==2) {
alert (\ ' Sorry, prohibit the use of this feature ^_^. \ ')
}
}
Document.onmousedown=click
</SCRIPT>
<script language= "JavaScript" >
<!--
locate = 0;
function Scroller () {
if (locate!=500) {
locate++;
Scroll (0,locate);
Cleartimeout (timer);
var timer = settimeout ("Scroller ()", 3);
Timer
}
}
-->
</script>

2 Web page Security Technology Guide

With the rapid development of the Internet, the number of websites is increasing in geometry, the information on the Web page is very rich, but the security of the website and the copyright of the information are constantly under threat. Recently, the world's major websites have been hackers attack, and then, in order to adapt to the new situation, The first domestic network security topic was born. Web site and the security of the Web page more and more attention, this article will be introduced to enhance the security of the Web page of various technologies and skills, to care about the source code copyright and Web page Data Security protection readers have a greater help.

Beginner's Introductory article

For the vast number of Web page writers, the protection of the source code is the most concerned, but often there is no way. Hard to write the Web page in front of the browser without cover, as long as someone else gently click the right mouse button, select (View source code), you can get the full web page code, Even slightly modified to become someone else's Web page. This article will be through the use of JavaScript technology, the page source code changes, so that viewers can not obtain the source code, to protect the purpose of coding.

First, you should mask the features of the Internet Explorer toolbar-view-source code. The way the page is framed. If your page does not use a frame structure, and you do not need to use the frame structure, you can use the "0 frame" technology (the page will be divided into about two frames, the width of the left frame is 1, The right frame is the original page). The code for the method is as follows:

<title> Welcome to the web Teaching network </TITLE>
</HEAD>
<frameset cols= "1,*" frameborder=0 framespacing=0>
<frame src= "PS. HTM "Name=" Count "Noresize scrolling=no>
<frame src= "Search." HTM "name=" Search "noresize>
</frameset>

Save the file as the main file index.htm, create an empty file ps.htm, the original paging file is now saved as index.html (only slightly different from the main file name on the extension). The 0-frame technology has the following advantages:

1. Browsers in the toolbar with the source code items can not directly get the page code, only to get the framework of the main file code (that is, the above code).

2. Can use the left frame file ps.htm to load some advanced application of the webpage, such as background music, web counter, cookie application and so on.

Second, you should screen the right mouse button to display the source file function, that is, in the required protection of the paging file (index.html file in the example above) to add the following code: (When the right button is clicked will appear in Figure 1 the prompt box)

<script language= "JavaScript" >
function Click () {
if (event.button==2| | event.button==3) {alert (\] What do you want to do with the right button? "^_^\') }}
Hints can be customized in quotation marks
Document.onmousedown=click
</script>

Finally, to prevent some people who understand the language of the Web page from writing the code by manually finding the protected page through the connection in the frame master file, you should also include the following in the protected page:

<script language= "JavaScript" >
if (top==self) top.location= "index.html"
</script>

This code will provide the ability to jump back so that the browser cannot see the page directly, but instead automatically jumps back to the frame master file index.html to protect the page.

After completing the three steps above, after you have modified your homepage according to the frame structure, your homepage source code will not be available to the viewers on the Internet, you can celebrate the small.

In addition, if you do not want to use the frames page, you can open the new browser window in a special way, combined with the screen mouse function code can also receive the same effect, open the method as follows:

<a Href=javascript:window.open ("key.html", "the title of the protected page", "height=170,width=290,left=0,top=0,toolbar=0,location=0 , directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0 ") target=_blank> Open the connection to the protected page </a >

In code, key.html is the file name of the protected page. The height of the new window and width of the value can be customized by the user, in pixels.

Note: Embedded JavaScript code should be added to the

Intermediate Depth Chapter

In the last chapter, we use JavaScript technology to protect the online Web page. The so-called "strong in their own strong hand", some people use webzip,telepro,offline and other offline browsers to download your homepage, you can bypass JavaScript protection online web page defense, Download the Web page and then analyze it slowly. A spear has a shield, and you can also use JavaScript to create a dynamic steering file that most offline browsers can't download your Web page, as follows. You can rename the protected page in the previous example to Index1.html, Instead, change the file index.html to the following code:

<script>
Window.location.replace (\ ' index1.html\ ')//This sentence produces the page jump function
</script>

The new Offline browsing feature for the Internet Explorer5 (working offline), which sometimes fails, can be protected with advanced technology that sets cookies on the Web page. Once the cookie is overdue, even if the page has been downloaded to the machine can not browse, oh, severe bar:

The cookie code snippet that should be added to the file is as follows:

<script language= "JavaScript" >
function Getcookieval (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr = = 1)
Endstr = Document.cookie.length;
Return unescape (document.cookie.substring (offset, endstr));
}
function GetCookie (name)
{
var arg = name + "=";
var alen = Arg.length;
var clen = document.cookie.length;
var i = 0;
while (I < Clen)
{
var j = i + Alen;
if (Document.cookie.substring (i, j) = arg)
Return Getcookieval (j);
i = Document.cookie.indexOf ("", I) + 1;
if (i = = 0)
Break
}
return null;
}
function Setcookie (name, value)
{
var argv = setcookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < ARGC)? ARGV[2]: true;
var path = (3 < ARGC)? ARGV[3]: true;
var domain = (4 < ARGC)? ARGV[4]: true;
var secure = (5 < ARGC)? ARGV[5]: true; Safe Mode takes effect
Document.cookie = name + "=" + Escape (value) +
((expires = null)? "" : ("; Expires= "+ expires.togmtstring ()) +
((Path = null)? "" : ("; Path= "+ path)" +
(domain = null)? "" : ("; domain= "+ domain)" +
(Secure = = True)? "; Secure ":" ");
}
function resetcounts (name)
{
visits = 0;
Setcookie (Expdate, "/", true, true);
Location.reload ();
}
</script>
<script language= "JavaScript" >
var expdate = new Date ();
var visits;
Expdate.settime (Expdate.gettime () + (24*60*60 * 1000)); Cookies extended time set, here is 1 days
if (!) ( visits = GetCookie ("visits"))
visits = 0;
visits++;
Setcookie (Expdate, "/", true, true);
</script>

If you have already done this, your Web site will be protected from the conventional sense of morality or copyright, but the true technical protection.

Advanced Research Articles

The protection of Web pages is not just about the protection of the source code, but also the protection of the Web page data or network database. The protection of the network database can be based on the IIS CGI interface authentication program, SQL Security technology, ASP Security authentication procedures, Java applet security certification procedures and other means, A higher level of security, including a large number of content, this article is not introduced. This article introduces the page authentication interface that is constructed with JavaScript technology. Add the following code to a page that requires data protection only for limited population access:

<script language= "JAVASCRIPT" >
<!--
Loopy ()
function Loopy () {
var sword = ""
while (Sword!= "Hibow") {
Sword = prompt ("Enter correct password login!")
}
Alert ("Identification ... Allow Login ")
}
-->
</script>

Note: Embedded JavaScript code should be added to the

The value of the field sword in code hibow the password for the login protected page. You can tell a custom password to allow users to access the page, only if the password is correctly entered after the browser can see the content of the page, otherwise the loop will be stuck in the password login box (see Figure 2), can't get in.

In order to protect the page source code and the best results of data, can be introduced in this article all the methods combined, this will test everyone's understanding and ability.

This is unable to lock code, as long as the first point Zuojian do not put, and then point right, left to build, you can see, if your home page is to use asp,php, or CGI purchased, generally the other side is not see the source code. Anti-right method is outdated and there is another way is to remove all the return, the entire file compression. This can not see clearly, but also does not affect the moving line.



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.