方法1
<script type="text/javascript">
function uaredirect(murl){try{
if(document.getElementById("bdmark") != null) {
return
}
var urlhash = window.location.hash;
if(!urlhash.match("fromapp")){
if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))){
location.replace(murl);
}
}
}catch(err){}
}
uaredirect("跳转的网址");
</script>
方法2
<script type="text/javascript">
function isMobile() {
if((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))){
return true;
}else{
return false;
}
}
var urlMobile='网址';//手机跳转的页面
if(isMobile() !== false)
window.location.href=urlMobile;
</script>

本文提供了两种用于检测用户是否使用手机浏览器并实现页面跳转的方法。方法一通过判断URL哈希值及User Agent来实现跳转;方法二则提供了一个更简洁的方案,直接通过User Agent进行判断。
618

被折叠的 条评论
为什么被折叠?



