2011-11-30 23 views
0

我正在研究基於raphaeljs的web應用程序。 我用鼠標點擊了& ctrl down事件作爲輸入。 但是,事實證明,當你點擊一個圖像元素而CTRL鍵關閉時,它會在新的瀏覽器選項卡中打開圖像。如何防止raphaeljs在mouseclick + ctrldown的新選項卡中打開圖像?

檢查出來(鼠標點擊到的圖像,同時按下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> 

如何預防呢?

回答

1

您是否嘗試過通過此圖像,jQuery或js在此圖像上綁定單擊事件。

$('svg img').click(function(){ 
return false; 
}); 
相關問題