2014-02-18 25 views
5

我已經實現ZeroClipboard功能上我們的網站 - http://couponvoodoo.com/rcp/Jabong.com/coupons-offers?field_offer_type_tid=All 我使用Drupal的7ZeroClipboard沒有對網站的移動版本工作

它工作正常的桌面版本,但不工作的移動版現場。 我已經把下面的代碼在頁腳:

<script type="text/javascript"> 
copy_coupon_footer(); 
function copy_coupon_footer(){ 
var divArray = document.getElementsByClassName("unlock_best_coupon"); 
for (var i = 0, len = divArray.length; i < len; ++i) { 
var offer_type = divArray[i].getAttribute('data-clipboard-text'); 
// alert('offer_type '+offer_type); 
try{ 
     var id = divArray[i].getAttribute('id'); 
     var client = new ZeroClipboard(document.getElementById(id), {moviePath:'/moviePath' }); 
     client.on('load', function(client) { 
     client.on('complete', function(client, args) {try{ 
     var url = this.getAttribute("href"); 
     var coupon_code = url.split('&c=')[1].split('&')[0]; 
     this.innerHTML = coupon_code; 
     var classname = this.className+' copied_coupon'; 
     this.setAttribute("class",classname); 
//  window.open(url,'_blank'); 
    window.location.href = url; 
     }catch(e){} 
     }); 
     }); 

    }catch(e){alert(e.message);} 
    } 
    return false; 
    } 

</script> 
+0

它需要瀏覽器上的Flash插件才能正常工作。 – techfoobar

+0

@techfoobar你能告訴我如何檢查Flash插件是否安裝在移動設備上(PS:我可以在瀏覽器上查看youtube視頻) – user2129794

+0

此頁面會告訴你安裝的plash插件的版本(如果已安裝) - http://www.adobe.com/software/flash/about/ – techfoobar

回答

4

ZeroClipboard需要安裝Adobe Flash爲了執行它的剪貼板功能,因此它不會在沒有安裝的Adobe Flash的任何瀏覽器。

因此,由於幾乎沒有任何帶有Adobe Flash的移動設備(只有一些較舊的Android設備),因此它不適用於移動設備。

當我詢問this question有關不需要Adobe Flash的ZeroClipboard替代方案時,沒有提供其他解決方案。

1

這個答案可能有點晚,但我創建了一個純粹的JavaScript替代zeroclipboard,非常容易使用。這裏是:Github repository。這裏是代碼:

function clip(text) { 
    var copyElement = document.createElement('input'); 
    copyElement.setAttribute('type', 'text'); 
    copyElement.setAttribute('value', text); 
    copyElement = document.body.appendChild(copyElement); 
    copyElement.select(); 
    document.execCommand('copy'); 
    copyElement.remove(); 
} 
+0

您的代碼有效!這幫了我很多。謝謝! – Vincent