我在互联网上搜索了很久,但是没有找到有效的解决方案。
我希望我的图片不会被选中,就像一个带有背景图片的div(<div style = "background-image : 'moo.png';"> </div>
)
我不能使用背景图片,因为我需要图片映射来实现功能。
我的代码看起来像这样:
css,
.filmmakers #map {
-moz-user-select : -moz-none;
-khtml-user-select : none;
-webkit-user-select : none;
-ms-user-select : none;
-o-user-select : none;
user-select : none;
}
.filmmakers #map::selection {
color : rgba(0, 0, 0, 0);
}
HTML,
<img id = "map" src = "WorldMap.png" alt = "Map" unselectable = "on" style = "left : 0px; top : 0px;" />
JavaScript,
var map = document.getElementById('map');
makeUnselectable(map);
function makeUnselectable(node) {
if (node.nodeType == 1) {
node.setAttribute("unselectable", "on");
}
var child = node.firstChild;
while (child) {
makeUnselectable(child);
child = child.nextSibling;
}
}
正如您所见,我仍然会得到拖动图标,并且它会影响地图的功能:
https://dl.dropbox.com/u/107533178/CampusRoyal/Filmmakers.html
请帮忙翻译,感谢您抽出时间阅读我的帖子,非常感谢您的关注。祝好!
Mithos