0

Hello there!

I'll make this short and simple. I need help with the following -
1. Disable right-click in my webpage,
2. Disable "View Page Source" option.

I've seen point no.1 implied in many websites, but haven't seen point no.2 anywhere. So can you help me with these?

Thanks in advance,
~Drift

4
Contributors
5
Replies
10
Views
6 Years
Discussion Span
Last Post by 098
0

1. Don't. It's annoying - and if someone wants to get something from your site, it will happen anyway.
2. You can't.

0

I see... well it would've been great if I could do it. You see twiss, I've been outsourcing websites recently, and I don't trust the people I work for, because they've ask for the whole website files before they pay me. On top of that, this client I worked for recently said he didn't like the website that I had made for him, that too after I sent him the files. Now, he has the files and I'm here redesigning the website again! Meaning, he's liable to sell the first design I had made, which is a loss for me. And you know the pain of losing something you'd worked so hard on. That's why I thought about uploading the website to a temporary domain, and upload it in such a way that the client cannot copy the website.

I know it's not possible, but if there is any nifty method for (somewhat) blocking a user from accessing the files, the it would be highly appreciated!

Once again, thanks in advance!

0

As far as I'm aware (but I'm not a lawyer) you're still the copyright owner and your client doesn't have the right to sell your site. Besides, it's always a good idea to ask half of the price you agreed on before you even start thinking about the website. And to show a quickly made example picture before you start coding, so that he can't say such things afterwards.

Last thing: if you give the document an onclick handler, you can check if the mouse button is the right (not left) one (#2) and return false in that case.

0

dear driftingsteps
If you your code is in pure html then you may not save your code from being stolen. But now a days I do not think any website in pure html.
So I guess you have developed your site in php-mysql or any other such language. If you deploy site on your dummy server and if user view source of copy it, then they could now see php source. So your work is safe.


Disabling right click is possible but I m not sure it will stop user from viewing source, because there are so many options to view source. Success of this script depends on browser settings.

You must write following line in all pages where you want to disable right click. I assue you copy offrightclick.js (attached) in js_script folder which is one level up your source.

<script src="../js_script/offrightclick.js" language="JavaScript"></script>

Edited by urtrivedi: n/a

Attachments
var BM = 2; // button middle
var BR = 3; // button right
var msg ="MOUSE RIGHT CLICK IS NOT SUPPORTED ON THIS PAGE";

function mouseDown(e) 
{ 
  try { if (event.button==BM||event.button==BR) {return false;} }  
  catch (e) { if (e.which == BR) {return false;} } 
}
document.oncontextmenu = function() { /*alert(msg);*/ return false; }
document.ondragstart   = function() { /*alert(msg);*/ return false; }
document.onmousedown   = mouseDown;
0

<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.