-5

First of all thanks in advance..

I want to disable view page source, copy and paste image etc .. in my web site.
How can I do it? I know php and javascript.

Blachshma
  • 17,097
  • 4
  • 58
  • 72
Testadmin
  • 2,880
  • 9
  • 49
  • 71

8 Answers8

12

There is no perfect way to do this.

You can cancel right mouse events with Javascript, but what if I disable Javascript?

Plus I can always do CTRL+U in Firefox to view the source.

And since the browser has to parse the HTML / Javascript in the end you can always see it in a debugger like Firefox.

Let go of the idea. It's impossible.

Anemoia
  • 7,928
  • 7
  • 46
  • 71
8

Don't bother. There is no foolproof way of doing this. Ultimately, if you're publishing the content (and source code), then you have to accept that other people will be able to copy it.

Any solution to this is going to rely on the user's browser cooperating, but the browser is under the control of the user, so you can't make this assumption. Usually it's simply a case of disabling JavaScript, which is trivial. It'll also be irritating and patronizing for many of your users.

Will Vousden
  • 32,488
  • 9
  • 84
  • 95
7

In short. You can't.

Disabling things like right clicking in Javascript are just annoying for end users. And it doesn't prevent them from saving the file or viewing the source from the browser menu or shortcut or various other means.

Don't bother.

Wim
  • 11,998
  • 1
  • 34
  • 57
7

This article will show you how to disable the right click, but let's remember these points:

  1. If the user has JavaScript disabled they will still be able to right click
  2. It's a massive usability issue, as it stops the user from using any other of the context menu functions
  3. If someone really wanted to copy / steal your content there are other ways, disabling right click is not the way to do it.

To be honest, trying to prevent a user from stealing content in this obtrusive manner is probably going to spur them on the find another method...

So in short, think twice before implementing this.

Ben Everard
  • 13,652
  • 14
  • 67
  • 96
5

Developers and clients who request these type of features just doesn't "get" what the internet and the www are all about.

leepowers
  • 37,828
  • 23
  • 98
  • 129
4

As far as I know you can't disable view source. You can use use tools like dotfuscator to make your code unreadable, but you can't disable view source.

You can disable copy-paste, but you shouldn't do that either. Here's a good discussion on that topic: Disable pasting text into HTML form

Community
  • 1
  • 1
Fedor Hajdu
  • 4,657
  • 3
  • 32
  • 50
2

Why do you want to do that? I hate sites that attempt to do that. It's possible to capture and suppress right click from javascript, but it's a poor solution that will only prevent users with very basic skills from viewing the source.

But I guess you could use flash or silverlight...

Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222
  • 2
    +1 for flash or silverlight. It's about the only way that you can prevent people stealing your stuff (assuming you secure the flash/silverlight files) which is what the OP asks for (even if they shouldn't be bothering anyway). – Blair McMillan Jan 05 '10 at 10:41
  • Content can also be stolen from Flash or Silverlight, everything that executes unencrypted on the client can be disassembled, modified and stolen. For instance, if Flash/SL loads images or content, you can sniff the http traffic and get the urls of the images. – Sune Rievers Jan 05 '10 at 10:44
0

An out of the box idea : Generate output in PDF

Pros:

  1. Users will be able to see it in browser window
  2. You can give rights to allow copy / even open using password

Cons:

  1. Users should have pdf reader such as adobe acrobat installed with browser extension.
  2. It is not a webpage
Salvin Francis
  • 4,117
  • 5
  • 35
  • 43
  • Obviously I am not asking to make your entire site in PDF :) just the content you dont want them to copy should be in pdf. – Salvin Francis Jan 05 '10 at 10:54
  • 1
    Or generate flash, or a bitmap. But the user can still take a screenshot :-) – Niki Jan 05 '10 at 10:57
  • btw, I wonder why you would require such functionality, showing content on the web and then disallowing users to copy it is equivalent to throwing a huge bundle of cash on the road and then expecting people not to pick up notes :D – Salvin Francis Jan 11 '10 at 05:22