如何防止raphaeljs在鼠标点击+按下键的新选项卡中打开图像

How to prevent raphaeljs from opening images in new tab on mouseclick+ctrldown?

本文关键字:选项 新选项 图像 鼠标 raphaeljs 何防止      更新时间:2023-09-26

我正在制作基于raphaeljs的web应用程序。我用鼠标点击&CTRL down事件作为输入。但是当你按下ctrl键点击图像元素时,它会在一个新的浏览器选项卡中打开图像。

检查一下(鼠标点击图像,同时按下ctrl键):

<div id="canvas" style="width:400px; height:400px;"></div>
<script>
   paper=Raphael("canvas",400,400);
    paper.image("https://www.google.com/logos/2011/twain11-sr.png",20,20,100,100);
</script>

如何预防?

您是否尝试过通过此库,jQuery或js在此图像上绑定单击事件?

$('svg img').click(function(){
return false;
});