We have learned about the time special effects in web page. They are easy and you just need to learn about some codes. Today let us learn how to forbid the web viewers to download images(save the images to local). This is a very common special effect in web page. Sometimes, you don’t want others to download your images for some reasons—-the images are so important and unique. But what shall we do to forbid others download our images? Yes, we still need the help of HTML codes. Firstly we definite a function; secondly we carry out the function. Take it easy. Now let us learn how to achieve this effect step by step.
Step1
Open your original web page in dreamweaver 8.0.
Step2
Choose the code view, and put the following codes in to the section between the <head> and </head>. Like the following picture showing:
- <script LANGUAGE="JavaScript">
- < !– Begin
- function protect(e) {
- alert("No downloading");
- return false;
- }
- function no() {
- if(document.images)
- for(i=0;i<document.images.length;i++)
- document.images[i].onmousedown = protect;
- }
- // End –>
- </script>
Now let us look at these codes. we definite a protect function to pop-off the alert message box, definiting a no() function to forbid image-download. You can definite the content of the message box by yourself.
Step3
Put “onLoad=“no ()” into the <body> sentence. It means that when the user open the web page, the page carry out the onLoad event and no () function.
Step4
Go back to the design view. Save the document and press F12 to preview in the Explorer. When you click the image in the Internet Explorer, there will be a message box appearing—-to tell you that you can’t download it.
OK. Now the special effect has been achieved successfully. Pay attention to the codes! we’d better remember that when the special effect is applied to the whole page, the codes will be put into the <head> sentence; or they will be put into the <body> or other sentences. We will learn how to create the mouse-follow effect in the next article.


Download Web Developer Toolbar for FireFox (https://addons.mozilla.org/en-US/firefox/addon/60)
Install
In the “Disable” menu choose “JavaScript” and select “All JavaScript”.
Reload the page, right click on image and “Save Image As”.
Or you can view the page source and copy the URL from the image and browse directly to it.
These JavaScript hacks to prevent users from downloading images really are a waste. The better solution is to simply provide a good license on your site which protects your IP.
@TJ
Hmm,that is advanced “skill”, I think these tutorials are writen for web designer or beginer, not for program developer.
And, in the other way, progammer/software company can encrypt the software, but hacker can decrypte it.
If there is a spear, shield will be invented. right?