href のリンク インテントを http:// ではなく fb:// にする。
ただ、これは、iOS ではうまくいくのだが、android だとうまくいかない。
何年か前に仕様が変わった?
<a href="#" onclick="clickFBApp()"><font size=80>LINK A</font></a>
<script>
function clickFBApp() {
if (
navigator.userAgent.indexOf('iPhone') > 0
|| navigator.userAgent.indexOf('iPad') > 0
|| navigator.userAgent.indexOf('iPod') > 0
)
{
document.location = "fb://profile/9999999999";
var time = (new Date()).getTime();
setTimeout(function(){
var now = (new Date()).getTime();
if((now-time) < 400) {
document.location = "https://itunes.apple.com/jp/app/facebook/id284882215?mt=8&uo=4";
}
}, 300);
}
else if(navigator.userAgent.indexOf('Android') > 0)
{
document.location = "intent://page/9999999999#Intent;scheme=fb;package=com.facebook.katana;end";
// document.location = "intent://profile/9999999999#Intent;scheme=fb;package=com.facebook.katana;end";
}
else {
document.location = "https://www.facebook.com/xxxxxxxx/";
}
};
</script>
参考:
https://www.tcmobile.jp/dev_blog/programming/url%E3%82%B9%E3%82%AD%E3%83%BC%E3%83%A0%E3%81%8B%E3%82%89%E3%81%AE%E3%82%A2%E3%83%97%E3%83%AA%E8%B5%B7%E5%8B%95%E3%83%BB%E3%82%A2%E3%83%97%E3%83%AA%E3%81%8C%E7%84%A1%E3%81%91%E3%82%8C%E3%81%B0/
https://takeshiyako.blogspot.jp/2015/08/android-open-facebook-page.html
twitter intent