我已经在我们的网站上实现了 ZeroClipboard 功能 - http://couponvoodoo.com/rcp/Jabong.com/coupons-offers?field_offer_type_tid=All 我正在使用 Drupal-7
它在桌面版上运行良好,但在网站的移动版上运行不佳。 我已将以下代码放在页脚中:
<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>
最佳答案
ZeroClipboard 需要 Adobe Flash 才能执行其剪贴板功能,因此它无法在任何未安装 Adobe Flash 的浏览器中运行。
因此,由于几乎没有任何移动设备带有 Adobe Flash(只有少数较旧的 Android 设备),因此它无法在移动设备上运行。
当我问 this question关于不需要 Adobe Flash 的 ZeroClipboard 替代方案,没有提供其他解决方案。
关于javascript - ZeroClipboard 不适用于该网站的移动版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21846010/