Free tech support / small logo


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!





Categorized: HTML and CSS   (Article 4204, Written by )
Tagged:
Previous: How do I export MP3 files from iTunes?
Next: How do I use IRC on a Mac?




Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
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

IS there no way I can restrict users to look at the images directly from folder.

Posted by: Alok Kumar at March 31, 2010 4:00 AM

Actually, Alok, there is. Just create an empty "index.html" (or the equivalent for your particular Web server configuration) and drop it in the images directory or folder. That should do the trick!

Posted by: Dave Taylor at March 31, 2010 6:25 AM

Hi, I am wanting to prevent the iPad users from being able to select images from my site and using the Save Image option (when they press finger down for 3 seconds on image) I have managed to prevent the cut/copy of text with -webkit-user-select: none; but require an option to disable the image selection from the ipad.
Many thanks

Posted by: Spencer Parkes at August 19, 2010 5:06 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 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.









Recent Entries


Search
I Need Help!
Need Help? Ask Dave Taylor!


© 2002 - 2012 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.