Important alert: (current site time 7/15/2013 2:01:02 PM EDT)
 

VB icon

Fool Proof No View Source Script

Email
Submitted on: 1/26/2000
By: Zilver Ztream  
Level: Beginner
User Rating: By 4 Users
Compatibility: JavaScript
Views: 52629
 
     Makes it kind of hard to get the source from a page. This code has been on javascripts.com for a while and I won code of the month ince with it, but I also recived over 11500 mails becuase of it so I hope that wont be needed here.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Fool Proof No View Source Script
' Description:Makes it kind of hard to get the source from a page.
This code has been on javascripts.com for a while and I won code of the month ince with it, but I also recived over 11500 mails becuase of it so I hope that wont be needed here.
' By: Zilver Ztream
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1745&lngWId=14'for details.'**************************************

Add this line to/ instead of your body tag:
(In a standalone HTML file before your protected page)
<body bgcolor=black onload="window.open('fullproof.htm','','halfscreen,scrollbars')">
ADD this script at the bottom of your page, just before your </body> tag.
(in the page you want to protect)
<script language=JavaScript>
 <!--
var message="ENTER YOUR CUSTOM MESSAGE HERE";
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// --> 
</script>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
2/27/2000 12:09:06 AMJoseph Then

Yes, this is the code that will somehow prevent people to right-click and copy the source code.

However, do remember that there is a view source command in IE and NS. Thus this method is still rendered useless.

But, the workaround is to put all the code into a frame, that will make the view even more fool-proof. :>
(If this comment was disrespectful, please report it.)

 
3/6/2000 8:59:06 PMiNfO

Hello, well, for IE, you can clic View>>Source , or on your keyboard, click on the button bottom button between then windows and control button, it will show you the menu, then you cna view the source, if ANYONE knows how to prevent these, please e-mail me, HandleisiNfO@cs.com
(If this comment was disrespectful, please report it.)

 
8/22/2000 6:06:55 PMPaC

nothing is view source proof. if you ever programming with sockets in any language its real easy to get source code of page. people need to just realise if you dont want things stolen, dont publish. i for one hate thiefs, but thiefs will be thiefs
(If this comment was disrespectful, please report it.)

 
8/22/2000 11:09:15 PMMichael

For a web page to be displayed on the users computer, a copy of it first needs to be downloaded to it. By default, these are stored in the Temporary Internet Files Folder, and can be accessed on or offline with ease. In this folder is a copy of all pictures, source code, js files and HTML files. There is nothing you can do to prevent this. Again, all prevent right click scripts have a limit on them: when right-clicking, hold the right button whilst the alert comes up, press ENTER or the space bar to clear the alert, then release the right button, voila! source code! But the above method is about as hard as you can make it..but it will only stop the kind of people who aren't interested in source code anyway.
(If this comment was disrespectful, please report it.)

 
8/29/2000 2:26:24 PMThe VeNd

Love the code, do you have code to block view source in Netscape as well?

-vendimaan@yahoo.com
(If this comment was disrespectful, please report it.)

 
12/30/2000 12:08:18 PMSORD

You could get a HTML stealer and view it easily...even in a frame because then you get the web page's address to the main page. You can't hide source code, there will always be someone able to get it. The only other way is to find someway to encrypt the page but still be able to load it. This will also just slow people down but people that aren't extremely smart wouldn't be able to get the source.
(If this comment was disrespectful, please report it.)

 
1/8/2001 6:41:56 PMRobert

Also you can view source of the STANDALONE PAGE to get the name of the PROTECTED PAGE to put in replace of the STANDALONE PAGE to bring up the PROTECTED PAGE in the window of the STANDALONE PAGE to view source of the PROTECTED PAGE. Or maybe, just write your own d**n code. (Steal Code from others as you would have them steal code from you.)...
(If this comment was disrespectful, please report it.)

 
7/17/2001 9:47:16 AMJonathon Cebula

This is not fool proof, so why call it fool proof, I'm pretty sure a fool could find a way around it. There is much better methods, have a look at them on this site.
(If this comment was disrespectful, please report it.)

 
10/1/2001 2:37:05 PMLara

I found a sight where, right clicking is allowed, but when you open their view source (by right click or by going to the brower menu View then choosing source), a .txt opens with their chosen copyright message. And even after I saved their site onto my pc and went through every bit of it, I could not find the code they used to do it. Anyone know what I'm talking about?
(If this comment was disrespectful, please report it.)

 
6/28/2002 12:11:11 PM|)/-\r/<$!|)3

/-/3~/_!_/-\(\/)_/\/0-|-_/-\_1~00l_/-\11_!_|)0_!$_|)!$/-\|313_(//-\\//~\_$<7!|0-|-_!/\/_ !/\/-|-3r/\/3-|-_><|01073r
(If this comment was disrespectful, please report it.)

 
8/7/2002 9:13:41 PMnoize

Well they say it is fool proof... how likely is that? Just like they said the titanic couldn't since, this script is nothing more then something for a source stealer to laugh at all day long. Well I guess I will get to the point of why it isn't fool proof... yes it prevents people from right clicking but it suppose to protect the source. You can easily click both mouse buttons at the same time in IE and get the right pop up menu... well guys never believe anyone in the future when they tell you something is fool proof.
(If this comment was disrespectful, please report it.)

 
10/2/2002 11:47:46 PM

to view the source of any page just put the prefix view-source: in front of the page. for example, if i wanted to view the source of yahoo's site i would put in the address bar view-source:http://www.yahoo.com and the source pops rite up. just a neat little hacker trick i picked up along the way
(If this comment was disrespectful, please report it.)

 
10/23/2002 2:41:10 PM

You CAN access the source code... All you have to do is hold the LEFT mouse button and press the RIGHT button...
(If this comment was disrespectful, please report it.)

 
3/7/2003 3:29:30 PMMrEnigma

http://summerholiday.org/freecode/Right_Click_-_Context_Sensitive_Menu(with_no_View_Sour ce_or_Save_Image_As).html
(If this comment was disrespectful, please report it.)

 
12/5/2003 2:44:11 AM

You can also click the right button then enter in sequence till the menu pops up,its easier to just to click the right button then left together.
(If this comment was disrespectful, please report it.)

 
1/23/2004 8:52:49 PMMark Kahn

http://www.cwolves.com/testing/getmysource.asp
(If this comment was disrespectful, please report it.)

 
4/16/2004 5:09:19 AM

I love this code!!! it works for me!!!
(If this comment was disrespectful, please report it.)

 
8/30/2004 9:53:22 AM

Here is a workaround for the middle button deal.

// -->


Please let me know if this solved your issue.

RM
WebDev
(If this comment was disrespectful, please report it.)

 
1/22/2009 5:23:22 PMAmnite

Just Use The Simple Anti Anti Right Click To Disable
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.