Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I protect images?

Status
Not open for further replies.

TimCritchfield

Technical User
Aug 27, 2001
19
US
I used this code on my site but it didn't work.

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<title></title>
<meta name=&quot;Description&quot; content=&quot;&quot;>
<meta name=&quot;Keywords&quot; content=&quot;&quot;>
<meta name=&quot;Author&quot; content=&quot;thomas critchfield&quot;>
<meta name=&quot;Generator&quot; content=&quot;AceHTML 4 Freeware&quot;>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->

<!-- Begin
function protect(evt)
{
if (navigator.appName != 'Microsoft Internet Explorer')
{
if (evt.which != 3)
return true;
};
alert(&quot;Sorry, you don't have permission to right-click.&quot;);
return false;
}


function trap()
{
if(document.images)
{
if(navigator.appName != 'Microsoft Internet Explorer')
{
for(i=0;i<document.images.length;i++)
document.images.onmousedown = protect;
}
else
{
for(i=0;i<document.images.length;i++)
document.images.oncontextmenu = protect;
}
}
}

// End -->
</SCRIPT>

</head>
<body OnLoad=&quot;trap()&quot;>

How do I use this code? Can someone give me an example?
 
Tim, I can't answer your question, but I can give you a posting tip. Notice that about halfway down your code goes from normal text to italic? I'll bet that the line:
Code:
document.images.onmousedown = protect;
is supposed to be:
Code:
document.images[i].onmousedown = protect;
The missing
Code:
[i]
was taken by TT to be a TGML tag for italic (just like <i> in html). To prevent that from happening, always enclose your code in [ code ] and [ /code ] tags (without the spaces, of course). That's how I got the
Code:
[i]
to display twice in this paragraph.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top