检测移动浏览器和javascript支持 [英] detect mobile browser and javascript support

查看:116
本文介绍了检测移动浏览器和javascript支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测请求是否来自移动浏览器(我使用java/jsp)

I want to detect if the request is coming from a mobile browser (i m using java/jsp)

现在,当我从三星手机访问该页面时,我得到的用户代理标头为:-

Now when i access the page from my samsung mobile phone i get the user agent header as: -

SAMSUNG-GT-S5620/S5620DDJE1 SHP/VPP/R5 Dolfin/1.5下一个SMM-MMS/1.2.0配置文件/MIDP-2.1配置/CLDC-1.1

SAMSUNG-GT-S5620/S5620DDJE1 SHP/VPP/R5 Dolfin/1.5 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1

我应该检查标题包含iPhone,BlackBerry,Android,webOS,iPod,Samsung还是有一些更简单的方法...

should i check that the header contains iPhone,BlackBerry,Android,webOS,iPod,Samsung or there is some more simple way...

我如何确保浏览器支持javascript和

How can i make sure that the browser supports javascript and

顺便说一下,移动浏览器是否支持hashchange或任何js"高级"

by the way does mobile browsers suppport hashchange or anything js "advanced"

如果移动浏览器不支持javascript,那么我想以一种形式重定向到一些简单的页面...

If javascript is not supported by the mobile browser then i would like to redirect to some simple page with a single form...

或者我必须为移动浏览器创建一个简单的页面,以使其在有或没有 js支持的情况下都能很好地运行

or i have to make a simple page for mobile browser such that it runs well with or without js support

谢谢

推荐答案

您可以使用 WURFL 之类的东西来查看浏览器是否具有某种程度的Javascript支持.

You can use something like WURFL to see if the browser has some level of Javascript support.

但是,您无法确定浏览器是否启用了Javascript或该特定设备上浏览器的特定版本支持哪些Javascript功能.

You can't, however, tell if the browser has Javascript enabled or which Javascript features are supported by the particular version of the browser on that particular device.

您应该改为在浏览器中使用渐进增强功能,通过测试所需的特定功能来添加基于Javascript的功能.

You should, instead, use progressive enhancement in the browser to add Javascript-based functionality by testing for the specific functionality required.

这篇关于检测移动浏览器和javascript支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆