比如说,我在桌面上,或者在没有Viber应用程序的Android上。我按下它,什么也没发生。应该显示通知消息,例如";安装Viber应用程序"或者类似的东西。我只有这个:
<a href="viber://forward?text=text">Click here to share!</a>
我试过这些:
<a href="whatsapp://send/?phone=62812345678&text=test" id="openWA">Send to WhatsApp</a>
<br>
<a href="viber://forward?text=paff" id="openV">Send to Viber</a>
<!-- Auto open on WebView and Firefox -->
<script>
document.querySelector('#openWA').addEventListener('click', function() {
var f = Date.now(),
j = setTimeout(function() {
if (Date.now() - f > 1250)
return;
alert('WA not installed')
}, 1e3);
});
document.querySelector('#openV').addEventListener('click', function() {
var f = Date.now(),
j = setTimeout(function() {
if (Date.now() - f > 1250)
return;
alert('VIBER not installed')
}, 1e3);
});
</script>
但上面写着";未安装";,不管是不是。
尝试使用此
<a href="#" id="openWA">Send to WhatsApp</a>
<br>
<a href="#" id="openV">Send to Viber</a>
<!-- Auto open on WebView and Firefox -->
<script>
document.querySelector('#openWA').addEventListener('click', function() {
setTimeout(() =>{
alert("Whatsapp not installed")
}, 500)
window.location.replace('whatsapp://send/?phone=62812345678&text=test')
});
document.querySelector('#openV').addEventListener('click', function() {
setTimeout(() =>{
alert("Viber not installed")
}, 500)
window.location.replace('viber://forward?text=paff')
});
</script>
有关更多信息,请参阅此stackoverflow帖子如何使用javascript 检查应用程序是否已安装