PHP如何检测jQuery mobile A级浏览器服务器端?

发布于 2024-12-16 18:48:38 字数 422 浏览 2 评论 0原文

当手机没有 jQuery Mobile 列出的“A 级”支持时,我想从我的标头中排除 jQuery Mobile JS 库 (http://jquerymobile.com/gbs/)。我发现在旧的黑莓手机(支持 JS)上,jQM 框架将这些手机磨成蜗牛般的速度。

举个例子,这些人在提供 jQuery Mobile 库和相关样式方面做得很好,具体取决于移动浏览器支持: demo.livebookings .biz

我如何实现类似的服务器端方法,以便我可以根据移动浏览器支持选择何时包含 JS 文件(例如 jQM 框架)和任何 CSS 文件。

谢谢

I want to exclude the jQuery Mobile JS library from my header when a phone does not have "A grade" support as listed by jQuery Mobile (http://jquerymobile.com/gbs/). I find that on old Blackberry phones (that support JS) the jQM framework grinds these phones to a snails speed.

As an example these guys do a good job at serving up the jQuery Mobile library and associated styles depending on the mobile browser support: demo.livebookings.biz

How can I implement a similar server-side approach so that I can choose when to include JS files (e.g. jQM framework) and any CSS files as per the mobile browser support.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囍孤女 2024-12-23 18:48:38

jQM 功能是客户端,更多信息请参见:

gradeA 返回布尔值的函数,默认:返回 $.support.mediaquery 值的函数

任何支持条件
必须满足才能继续。

对于服务器端,您需要类似

我以前使用过 Mobile ESP 并且取得了很好的效果与它。扩展/自定义

The jQM functionality is Client Side, More on this here:

gradeA function that returns a boolean, default: a function returning the value of $.support.mediaquery

Any support conditions
that must be met in order to proceed.

For Server Side you would need something like

I've used Mobile ESP before and have had great results with it. It's also easy to extend/customize

左秋 2024-12-23 18:48:38

您必须使用浏览器用户代理来完成此操作,但由于有很多浏览器很难自己完成(并保持最新),WURFL 是一个库,它可以为您完成所有艰苦的工作,计算出手机型号并为您提供手机功能。

使用此功能,您可以了解手机的浏览器是否具有某些功能,并且根据您所说的“A 级”,您是否可以使用 JS 库。

他们有一个非常糟糕的网站,但是有详细的库和 PHP 可供阅读和使用。缓存一切都给你了。

You have to do this by using the browsers user agent, but as there are so many its hard to do by your self (and keep it upto date), WURFL is a library that does all the hard work for you, works out the phone model and gives you the phones capabilities.

Using this you can find out whether the phone has certain features within the browsers and depending on what you call "A-grade" you can use JS libraries or not.

They have a pretty horrible website but the detailed library and PHP to read & cache it is all given to you.

ゞ记忆︶ㄣ 2024-12-23 18:48:38

您可以使用 jQuery $.support() 方法通过功能检测在客户端执行此操作:

<script src="jquery-1.6.4.js"></script>
<script>
//check to see if media queries are supported (this is how the jQuery Mobile framework detects "grade A" browsers), $.support.mediaquery returns true or false
if ($.support.mediaquery) {

    //if support is found then load the jQuery Mobile JS file
    $.getScript('jquery.mobile-1.0.js');
}
</script>

http://api.jquery.com/jquery.support

http://api.jquery.com/jquery.support jquery.com/jquery.getscript

You can do this client-side by feature detection using the jQuery $.support() method:

<script src="jquery-1.6.4.js"></script>
<script>
//check to see if media queries are supported (this is how the jQuery Mobile framework detects "grade A" browsers), $.support.mediaquery returns true or false
if ($.support.mediaquery) {

    //if support is found then load the jQuery Mobile JS file
    $.getScript('jquery.mobile-1.0.js');
}
</script>

http://api.jquery.com/jquery.support

http://api.jquery.com/jquery.getscript

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文