我有这个代码从我的网站链接打开我的Facebook页面。 但是当在移动浏览器上浏览我的页面时,它也会在浏览器中打开facebook链接,但是我想在应用程序中打开facebook页面(如果已安装)。 这是我的代码
<script type="text/javascript">
$(function () {
$("select#CountryID").change(function (evt) {
if ($("select#CountryID").val() != "-1") {
$.ajax({
url: "/Home/GetStates",
type: 'POST',
data: { CountryID: $("select#CountryID").val() },
success: function (response) {
$("#stateID").empty();
$("#stateID").view(response);
},
error: function (xhr) { alert("Something seems Wrong"); }
});
}
});
});
</script>
答案 0 :(得分:1)
将//facebook.com
替换为fb://
<a href="fb://myfacepage/" target="_blank" rel="alternate"><img src="images/facebook-logo.png" alt="" /></a></p>
答案 1 :(得分:0)
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'], "Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'], "webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'], "BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'], "iPod");
//check if is a mobile
if ($iphone || $android || $palmpre || $ipod || $berry == true) {
$device = 'mobile';
}
//all others
else {
$device = 'desktop';
}
?>
<html>
<ahref="<?php echo ($device=='mobile')?'fb://':'https://www.facebook.com/'; ?>zuck">Facebook</a>
</html>