2014-04-29 124 views
1

在我的應用程序中,特別是div,我想用選項顯示自定義右鍵單擊菜單,而不是默認瀏覽器菜單。如何禁用瀏覽器的默認右鍵單擊菜單

我試着用下面的代碼。

events: { 
    "contextmenu #navContainer":"rightClickTest" 
}, 
rightClickTest:function(event){ 
if (event.button == 2){ 
    alert("Right Click is not possible Here !") 
    } 
} 
我們現在用 backbone.js我Application.Event工作正常,但問題是事件邏輯完成後

,默認顯示爲通常右鍵菜單。

注:

我想禁用默認右鍵菜單在我的應用程序的特定的div(navContainer)。

我該如何解決這個問題。

+0

@rajmathan也許你會感到驚訝,但它也有已經回答*有* – nicael

回答

4

這應該做到這一點..

rightClickTest:function(event){ 
    if (event.button == 2){ 
    event.preventDefault(); 
    alert("Right Click is not possible Here !") 
    } 
} 
+0

其實我發現solution.But我忘了張貼的答案。無論如何感謝您的寶貴答案。 – user3279058

相關問題