我是在谷歌浏览器中测试的,百度的搜索结果都没什么用,最后在谷歌搜索出了答案。
地址:http://stackoverflow.com/questions/4211909/disable-dragging-an-image-from-an-html-page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>中国站长天空-网页特效-鼠标特效-禁止鼠标拖动图片在新窗口打开</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代码加到<head>与</head>之间-->
</head>
<body>
鼠标左键拖动图片试试!
<a href="http://cleopard.download.csdn.net">更多免费资源</a>
<!--把下面代码加到<body>与</body>之间-->
<img src="http://www.csdn.net/css/logo.png">
<img src="http://avatar.csdn.net/2/0/B/1_cleopard.jpg" >
</body>
</html>
<script>
console.log(document.getElementsByTagName('img'));
document.getElementsByTagName('img')[0].onmousedown = function(e){
e.preventDefault()
};
</script>
修改后代码,运行成功。