html网页判断手机还是电脑登陆进入

html-css09

html网页判断手机还是电脑登陆进入,第1张

1、首先根据下方的代码,进行输入编辑。

<script type="text/javascript">

try{

if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {

window.location.href="mindex.html"

2、然后继续根据下方的代码,进行输入编辑。

}else{

window.location.href="cindex.html"

}

}catch(e){}

</script>

3、然后这样就可以判断手机还是电脑登陆进入了。

你可以把手机浏览器设置成电脑版本的试试看啊!有的网站不支持转手机版本登录,有的模板错误都会出现这种情况的。就看你网站采用了什么写法,如果你网站是flash那就打开有些困难了,网站要做html5+css3结合html+css来继续弄这个方面。

是因为电脑访问很流畅的东西不一定在手机登路上手机没有连接或下载所以登不上电脑版的html,还不能用于手机的浏览器打开,如果做了适配才可以的,这个不是什么bug去只支持电脑吧,不支持手机登录,有的电脑版跟手机版有分版本的。

var browser = {

versions : function() {

var u = navigator.userAgent, app = navigator.appVersion

return {//移动终端浏览器版本信息                                                              

mobile : (!!u.match(/AppleWebKit.*Mobile/) || !!u.match(/Windows Phone/) || !!u.match(/Android/) || !!u.match(/MQQBrowser/)) && !u.match(/iPad/)//是否为移动终端                                 

}

}()

}

if(browser.versions.mobile){

 window.location.href="http://www.xxx.com/wap.html"

}

加入index.html。