<title>禁止在图片上使用右键</title>
<script language="JavaScript1.2">
var clickmessage="无法完成操作!"
function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
}
function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}
if (document.all)
document.onmousedown=disableclick
else if (document.layers)
associateimages()
</script>
<img src="http://images.cnblogs.com/logo.gif">
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/mane_yao/archive/2010/03/24/5411070.aspx