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.

clip_image002

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:

clip_image004

  1. <script LANGUAGE="JavaScript">
  2.  
  3. < !– Begin
  4. function protect(e) {
  5. alert("No downloading");
  6. return false;
  7. }
  8.  
  9. function no() {
  10. if(document.images)
  11. for(i=0;i<document.images.length;i++)
  12. document.images[i].onmousedown = protect;
  13. }
  14.  
  15. // End –>
  16. </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.

Related Posts