lzsansi编码格式34@163.com。 怎么在手机上打开网站!

移动端访问网站自动跳转到手机版,大家都用的什么方法啊 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请 &
Sponsored by
国内领先的实时后端云野狗 API 可用于开发即时聊天、网络游戏、实时定位等实时场景传输快!响应快!入门快!
Promoted by
移动端访问网站自动跳转到手机版,大家都用的什么方法啊
08:29:17 +08:00用 iPhone 发布 · 2431 次点击
环境是 Python Tornado mako1. 在后端做根据不同设备渲染不同模板2. 在前端做根据不同设备做跳转另外前后端判断 PC 和移动设备怎么尽量覆盖更多的浏览器呢
7 回复 &| &直到
10:11:21 +08:00
& & 08:39:10 +08:00
&script type=&text/javascript&&
if(window.location.toString().indexOf('pref=padindex') != -1){
}else{
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf(&?mobile&)&0){
if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
window.location.href=&/index.htm&;
}else if(/iPad/i.test(navigator.userAgent)){
window.location.href=&/pad/&
window.location.href=&/simple/s/index/&
}catch(e){}
}
}
&/script&
& & 09:09:58 +08:00
楼上的改良版,http://steeeeps.net//get-client-type-by-useragent/
添加了 微信和nexus的判断
& & 09:20:28 +08:00
& & 09:24:54 +08:00
& & 10:04:47 +08:00
@ 请问你这个应该如何应用到网页中呢?
& & 10:10:18 +08:00
!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/) || &ontouchstart& in document.documentElement
& & 10:11:21 +08:00
上面的会包括pad
& · & 286 人在线 & 最高记录 2026 & · &
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.7.5 · 48ms · UTC 21:50 · PVG 05:50 · LAX 14:50 · JFK 17:50? Do have faith in what you're doing.}

我要回帖

更多关于 kalamansi 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信