2011-09-13 49 views
1

我遇到了taphold事件的問題。jQuery Mobile taphold事件觸發瀏覽器對話框

我將taphold事件綁定到圖像上。當我在飛行中拍攝圖像時,android web瀏覽器將激活一個包含「另存爲圖像」,「設置爲壁紙」,「共享圖像」命令的對話框。

我想在使用taphold事件時禁用圖像處理命令對話框。

可能嗎?

回答

0

調用e.preventDefault()以防止彈出對話框。

$page.bind("pageinit", function() { 
    $("a").bind("taphold", function (e) { 
     // your code 
     e.preventDefault(); 
    }); 
}); 

編輯:

怎麼樣,而不是綁定到IMG?

$page.bind("pageinit", function() { 
    $("img").bind("taphold", function (e) { 
     // your code 
     e.preventDefault(); 
    }); 
}); 
+0

沒有我的網頁上的「錨」 :( – doganak

+0

綁定到比錨以外的東西似乎不從我研究工作掃清了同樣的問題。 – bafromca

+0

這不起作用。 –

1

我發現你必須禁用右鍵單擊。

$(function(){ 

    document.oncontextmenu = function() {return false;}; 

    $(document).mousedown(function(e){ 

     if (e.button == 2) 
     { 
      alert('Right mouse button!'); 
      return false; 
     } 

     return true; 
    }); 
}); 
0

是的,這是可能的。我被下面的代碼

 window.oncontextmenu = function (event) { 
    event.preventDefault(); 
    event.stopPropagation(); 
    return false; 
     }; 
相關問題