Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How can I protect my Web site graphics?

How can I protect my website html pages, graphics, etc. from being viewed, and/or manipulated by casual viewers? IOW, what do I need to set up so that if someone tries to go to "www.mysite.com/pics" (for example), they would get a "no permission" message?


Dave's Answer:

There are two ways I can try to answer your question, actually. There's the far more complex question of how do you protect the content of your pages from prying eyes, and there's the simple question of how do you make it so people can't browse your "images" or "pics" directory.

Let's start with the first one. The essentially answer is that you cannot prevent people from manipulating your page, viewing the source HTML, JavaScript, CSS, etc., and even right-clicking on a graphic and using "Save Image As..." to grab a copy of what you have.

There are ways you can make it more difficult, including a common snippet of JavaScript code that disables the right-click feature while someone is on your page, but as with everything else that the Web site developer lives with, this is a case of "it's up to the browser". Specifically, if you can get something to appear on someone's screen, then they can take a screenshot, scrape the site with an archive program, or even browse their Web browser cache to get a copy of the image. For that matter, they can also ascertain the URL of your image and just reference that in an img src tag!

Here's a simple right click disable JavaScript snippet, by way of example:

<script language="Javascript1.2">

alertMsg = "Right-clicking on this page is disabled!";

browserVersion = parseInt(navigator.appVersion)
isNetscape = navigator.appName=="Netscape"
isIE = navigator.appName=="Microsoft Internet Explorer"

function noRightClick(evnt) {
  if (isNetscape && evnt.which > 1){
   alert(alertMsg)
   return false
  } else if (isIE && (event.button > 1)) {
   alert(alertMsg)
   return false;
  }
}

document.onmousedown = noRightClick;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (isNetscape && browserVersion < 5) window.onmousedown = noRightClick;

</script>

So that, as I said, is the complex half of this question. The simple half is, well, simpler!

If you want to prevent people from browsing your "pics" folder, simply create an empty file called "index.html" and drop it in that folder. If someone tries to browse the folder, they jsut get a blank page, but you can manipulate its contents to your heart's content using sftp or ftp.

Hope that helps you out!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    
Categorized: HTML and CSS   (Article 4204)
Tagged:
Previous: How do I export MP3 files from iTunes?
Next: How do I use IRC on a Mac?

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Another thing to do is to disable the directory listing in the web server software. Not everyone will have system administrator priviledge to do that, but if you do, it's a really simple setting.
That way, unless a visitor knows the exact file name or the directory has an index.html file, the server response will give a "file not found" error when they try looking.

Posted by: webGuru at May 31, 2006 11:29 AM

Disabling right click with Javascript is, in my opinion, an obnoxious nuisance! For instance, if I click the middle mouse button to scroll with Firefox, I get the "no right-click" popup. It's more useful for the site designer to disable hotlinked images than to prevent direct viewing of them.

Just my two cents.

Posted by: Chris Hepner at October 21, 2006 6:00 PM

http://ankurkhetrapal.com/blog/2008/01/12/protecing-your-images-on-the-web/

the author has discussed some neat methods to make image theft inconvenient

Posted by: chris at March 7, 2008 4:41 PM

Hi...how can i protect my blog photo and details from being copying by people?As i know microsoft internet explore have the security to protect blog from stealling by people,when the person right-click the mouse microsoft internet explore will show up a triangle yellow warning written the words "NO STELLING". Can i know how to put this microsoft internet explore warning in my blogger?Please help...

Posted by: Rachel at September 6, 2008 11:27 AM

thank you very much for your valubale coments

Posted by: SANJEEWA JAYASURIYA at April 12, 2009 6:09 AM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.








Ask Dave Taylor: The iPhone App: Advertisement


Uniblue: Free Virus Scan

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.