Very early wanted to write an article on the Web page source code screen. is because often make up some JS script, in the same time, also worry about the source code will be seen, steal my script. So all along, I've been trying to maintain the security of my web page source code. Although no completely safe shielding method has been found (that is, these methods have already known their weaknesses and methods when I think of them), but I have a lot of shielding ideas here to sum up.
As we all know, to protect a page, the most basic is to shield the right button. Now the most frequently used Web page is function click (), which is the following code:
〈script〉
function Click () {
if (event.button==2) {
Alert (' This website welcomes you!! ');
}
}
Document.onmousedown=click
〈/script〉
However, this method of shielding is also known to crack. That is, a continuous click of the left mouse button and right button will be able to see the right menu. However, I have seen a good way to shield the right button. The principle is different from what it says above. It is not written with JS script, but the use of the definition of page properties to play a limiting role. Moreover, in the shielding should try to avoid using JS script. Because as long as the viewer has disabled ie JavaScript script. Then all shielding is in vain.
So keep talking about the way you can modify the masking right button of a page's properties. This method uses the 〈body〉 in HTML to make changes, and it has only the following short line of code:
〈body oncontextmenu=self.event.returnvalue=false〉
Here, define the OnContextMenu. Causes the right key to be false, which has the effect of shielding the right key. Now, try the cracked method, and it's gone. The left and right key combo is no longer able to open the right-click menu. Not only this, but try the other way. No matter how messy you are, the right button is useless. Because on this page, the right button already does not exist. What can you do with a nonexistent function key?
However, shielding the right button does not solve the problem. If I want to copy a piece of text, or a picture. Then, select it and use CTRL + C to use CTRL + V to copy and paste it. By the way, the next thing to say is the left-screen button. Shielding left button? So this web page is not nearly wasted? Don't worry, don't finish, the left key is only one function is very annoying of the selected function.
Then, as mentioned above, using JS to shield is not used, the symptoms are not the root causes. So we're going to use the most basic language of the Web: HTML to define it. Or the old tricks, the definition of 〈body〉. The parameters used this time are: onselectstart. is the parameter selected by the left key. The code is as follows:
〈body onselectstart= "return false"
In this way, the left button to select the function is easily blocked. The principle is the same as above. Now, then use your left arrow to select any content, has no use. Naturally also cannot ctrl + C,ctrl +V. So now we're going to combine the two parts. Completely control about key! :
〈body Oncontextmenu=self.event.returnvalue=false onselectstart= "return false"
Now, the question about key is finally solved.
OK, now let's look at another question. As you all know, in the IE browser menu bar in the "View" item. There is a "View source code" option. So, although we have shielded the view source code in the right key. However, as long as you use the view Source code in the menu bar, you can still see the source code. What can we do about it?
My initial idea was to use a framework to circumvent the view of the source code. In other words, as long as a Web page is embedded in the frame, then the menu bar to select the view source code to see only the frame page source code. The general format is as follows:
〈html〉
〈head〉
〈meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "
〈title〉 this website title 〈/title〉
〈/head〉
〈frameset rows= "47,*" framespacing= "0" border= "0" frameborder= "0"
〈frame name= "header" scrolling= "no" noresize target= "main" src= "top.htm"
〈frame name= "main" src= "main.htm" scrolling= "Auto" target= "_self"
〈noframes〉
〈body〉
〈p〉 This page uses frames, but your browser does not support frames. 〈/p〉
〈/body〉
〈/noframes〉
〈/frameset〉
〈/html〉
This looks like the other side is not directly to see your source code. However, if a person wants to see your source code, then he must be able to read. If you understand a little HTML, you can see what these two sentences mean:
〈frame name= "header" scrolling= "no" noresize target= "main" src= "top.htm"
〈frame name= "main" src= "main.htm" scrolling= "Auto" target= "_self"
This means that the header (that is, the top of the page) refers to the Top.htm Web page file under the relative path. In main (that is, where most pages occupy the page), the Main.htm Web page file is referenced in the relative path. These two points is the key, the others do not explain, we all understand. The way to hide the source code using the framework above is to place the page in the main section. The header portion size is set to 0. But then, using the view Source code in the menu bar, you can still see the source code for the frames page. As long as we see these two sentences, we will know the way we used before. That is, as long as the name of the frames page changed to the target page, you can use the same method to see the source of the target page directly. For example: frames page: http://www.sina.com.cn/red.htm source code such as on, you can change to Http://www.sina.com.cn/main.htm. This can directly browse the protected Web page, shielding the effect of the source code is still not achieved.
Then, some people would think that if the other side does not see the source code of the frames page. What do you say to open the protected Web page directly? Yes, that's what I'm going to say next. If you want to view the source code in the menu bar of a page to be ineffective. The easiest way to do that is to get rid of the menu bar. And this can be done through pop-up windows. The reason why you do not use hyperlinks to open the No menu bar window is that it will expose the destination address, the viewer can directly in the browser typed address, and bypass the screen bar. To open a No menu bar window with a hyperlink, you must use a link in a Web page that has been protected by the source code.
So let's see how we can get rid of the menu bar using pop-up windows. In fact, all we have to do is to have the target page open in an ad bar. This code is available in almost every large web site. The code is as follows:
〈script〉
〈!--
window.open ("red.htm", "Red", "resizable=yes,width=500,height=300");
--〉
〈/script〉
Here, the first parameter in the parentheses after the window.open is the position of the page displayed by the pop-up window, where the red.htm page file is the first pair position. Then the run will talk about a window that shows a red.htm without a menu bar. Well, our purpose has been achieved. However, this window has a flaw, that is, there is no scroll bar. Because there is no argument about the scroll bar in the Statement of the window: window.open, or I don't know? Welcome to the Master letter pointed out that, so the Web page opened here to make the page to make the navigation page.
However, by using the above method to cancel the menu bar, there must be a second party Web page to do the pop-up work. The page that pops up the window, then, becomes a problem. For example, let's say we use a index.htm to work with pop-up windows. That is, after opening the index.htm, the Red.htm menu bar window pops up. We also mentioned earlier, if you know the address of a Web page, whether or not the page is hidden under the No menu bar, you can see its source code. Then, not letting this red.htm address be exposed is the key to solving the problem. However, as long as the index.htm is open, you can see the source code. But, think back, if we lock up index.htm? As long as the viewer does not have time to check the index.htm before it closes, you can keep its source code. Then, in this index.htm will have to do some articles.
That is, add the code to close the page.
current 1/2 page
1 2 Next read the full text