Analysis of methods to prevent others from viewing the webpage source code

Source: Internet
Author: User

A friend previously made a website, but was worried about someone copying the content and source code of his website. He asked how to prevent others from viewing the source code of his website? (Who would like to watch his website ...... It's a joke.) generally, some methods can be implemented to prevent others from viewing the source code of the webpage. below, let's simply analyze the torch points for everyone. If we want to prevent others from viewing the webpage source code, let's first analyze how others view the webpage source code. We generally know that Internet Explorer is Microsoft's IE browser. When you open a web page and wait until it is fully loaded, click "View" in the menu bar of the browser ", there is the "source file" option (or right-click the blank area on the webpage and select "View Source File" to view the source code of the webpage ). Nowadays, many people usually use JS to prevent others from viewing the source code of the webpage. There are also many specific methods. Here, the torch net provides you with several simple methods, however, since these are called "methods", there will inevitably be experts who can solve the problems. I. The following is a good method to prevent you from viewing the source code of the webpage. You can also try it.

<Html> <SCRIPT language = javascript> function click () {if (event. button = 2) {alert (\ 'sorry, disable this function ^_^. \ ')} 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>

 

In this second method, you need to add "<SCRIPT language = javascript> function click () {if (event. button = 2) {alert ('cannot be viewed! ') ;}} Document. onmousedown = click </SCRIPT>. 3. directly let you right-click the web page and the code of our application is invalid.
<script language="JavaScript"><!--if (window.Event)document.captureEvents(Event.MOUSEUP);function nocontextmenu(){event.cancelBubble = trueevent.returnValue = false;return false;}function norightclick(e){if (window.Event){if (e.which == 2 || e.which == 3)return false;}elseif (event.button == 2 || event.button == 3){event.cancelBubble = trueevent.returnValue = false;return false;}}document.oncontextmenu = nocontextmenu; // for IE5+document.onmousedown = norightclick; // for all others//--></script>

 

Iv. Shielding right-click menu viewing Mode
<Script Language = java script> function Click () {alert ('copyright (C) XXXltd. '); window. event. returnValue = false;} document. oncontextmenu = Click; </Script>

 

In this way, the shortcut menu will no longer appear no matter how you click the mouse. However, if you type "java script: alert (document. oncontextmenu ='') "in the address bar of your browser, you can remove the right-click menu. 5. Shielding window menu bar viewing (this method is actually a precaution for the fourth point). This method controls various properties of newly opened windows, including control menu bar, scroll bar, and whether the address bar is visible. If you close the parent window and hide the menu bar and address bar of the newly opened window, can you shield the display mode of the window menu bar? The implementation code is as follows:
<Head> <Object id = closes type = "application/x-oleobject" classid = "clsid: adb880a6-d8ff-11cf-9377-00aa003b7a11 "> <Param name =" Command "value =" Close "> </Object> </Head> <Body> <Script Language = java script> closes. click () window. open ("webpage file name .htm", "", "menubar = no, location = no, scrollbars = yes, resizable = yes") </Script> </Body>

 

In this case, the website's first page is created in the form of index.htm, And the homepage is designed as a transition page. After that, the real main page of the website will be created in the default.htm form (for the specific implementation process, see the source code attached to this Article ). In this way, visitors can no longer view the source code of the webpage. This not only protects your copyright, but also guarantees further development. In this way, you can combine Cookie technology to truly restrict users from browsing the Web page, so as to avoid illegal access to the home page information. But then again, why did Netease And Sina fail to prevent others from viewing the webpage source code? Is your little webmaster so emotional? Of course this is not the case. After all, those large websites may be different from those of some Internet enthusiasts. In addition, the torch points also want to point out that some Javascript scripts that disable page effects will become invalid in the Firefox browser. In addition, the Firefox webpage development plug-in will become even more powerful. So sometimes, when we are racking our brains and don't want others to view the source code, others can certainly compete with you in some ways! In fact, if people really want to see the source code, there is no way to block it, otherwise you can only encrypt the server. Writing this article is actually a little tired. I 'd like to talk about it with you at torch. Since you have made a website, it shows it to others. Are you afraid of viewing it? Even though we have done a lot of work, the experts still exist. What we need to do is not to prevent others from viewing the website, but to do a good job of Daily website maintenance. Although the domestic network environment is complex, it is not good to defend against such attacks! After the website is done, all the content is displayed in front of people. We will continue to do this kind of work. It is estimated that we want others not to plagiarize some interesting things, right? Haha ~ Of course, protection of web pages not only involves source code protection, but also includes protection of web page data or network databases. To protect network databases, you can use the IIS-based CGI interface authentication program, SQL security technology, ASP security authentication program, Java Applet security authentication program, and other means, it is a large part of high-level security measures. Protection of web pages is required, and daily maintenance is enough. Of course, you need to pay attention to the requirements for details. Sometimes, it doesn't matter if you view the Web Page code, after all, there are a lot of network resources, and others can also use other ways to move to some resources.

Related Article

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.