2016-12-07 110 views
7

我想知道是否有可能通過Javascript在iOS和Android上觸發「保存圖像」觸摸標註。標註由longpress觸發,但即使我試圖模擬這一點,它也不起作用。觸發iOS上的觸摸標註/ android

我想實現的東西喜歡這樣的:

jQuery('img').openCallout(); 

到目前爲止,我嘗試這樣做:

的jQuery:jQuery('img').contextmenu();
jQuery Mobile的:jQuery('img').taphold();

enter image description here

回答

2

是的,這可能使用jquery mobiledocs提到,使用taphold事件。(其他事件,我沒有嘗試

在本fiddle所示(到目前爲止在以下測試如圖所示here

$(function() { 
    $("div.box").bind("taphold", tapholdHandler); 

    function tapholdHandler(event) { 
    alert('Do you want to save the image or however it works in ipad'); 
    var a = document.createElement('a'); 
    a.href = "http://i.imgur.com/JzdY53y.jpg"; 
    a.download = 'JzdY53y.jpg'; 
    alert("goes till here1"); // just a check 
    a.click(); 
    alert("goes til here 2"); //just a check 
    } 
}); 
+0

但在這種情況下,它只是下載圖像和不顯示標註在我的PI上面的? – kindisch

+0

這是在鉻下載圖片沒有問,但這只是一個例子,我已經附加了'a'標籤,因爲我沒有平臺在iOS設備上測試//這只是一個參考,功能起作用。 –