如何定位黑莓浏览器?

发布于 2024-07-22 06:04:34 字数 413 浏览 9 评论 0原文

我使用以下内容来定位 iPhone 和手持设备,以使用特定的移动样式表,但黑莓浏览器仅选择常规的屏幕样式表。

<link media="handheld, only screen and (max-device-width: 320px)" href="mobile.css" type="text/css" rel="stylesheet" />
<link media="only screen and (max-device-width: 480px)" href="mobile.css" type="text/css" rel="stylesheet" />

我测试过该网站的所有其他移动设备都选择了正确的样式表。

有谁知道如何针对黑莓浏览器执行相同的操作?

谢谢!

I am using the following to target iphones, and handheld devices to use specific mobile styles sheets but the Blackberry browers is picking up only the regular screen style sheets.

<link media="handheld, only screen and (max-device-width: 320px)" href="mobile.css" type="text/css" rel="stylesheet" />
<link media="only screen and (max-device-width: 480px)" href="mobile.css" type="text/css" rel="stylesheet" />

All the other mobile devices I've tested the site on are picking up the correct style sheets.

Does anyone know a way to target the Blackberry browser to do the same?

Thanks!

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

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

发布评论

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

评论(5

屋顶上的小猫咪 2024-07-29 06:04:34

目前移动浏览器的状态非常混乱,我不建议尝试在客户端中检测版本。 最可靠的方法是使用 WURFL http://wurfl.sourceforge.net/并在服务器端进行所有检查。

祝您在黑莓上一切顺利! 哦,别忘了,运营商可能会在你的 HTML 到达手机之前就对其进行修改。

The state of mobile browsers is such a mess at the moment that I would not recommend trying to detect versions in the client. The most reliable way to do it is to use something like WURFL http://wurfl.sourceforge.net/ and do all your checking server side.

Good luck getting anything working nicely on the blackberry! Oh and don't forget to that the carriers might be screwing with your HTML before it even gets to the phone.

北渚 2024-07-29 06:04:34

我最终使用 Javascript 来检测用户代理。

然后,如果是移动设备,则打印手持设备和屏幕的 mobile.css(因为 BlackBerry 和 iPhone 认为它们是屏幕);如果不是移动设备,则打印常规样式表。

它不适用于任何没有 Javascript 的设备,但无论如何,他们最好还是查看该网站的基本版本。

I ended up using Javascript to detect user agents.

Then printing mobile.css for handheld and screen if it is a mobile device (because the BlackBerry and iPhone think they are screens) and printing the regular style sheets if it isn't a mobile device.

It doesn't work for any device that doesn't have Javascript but they are probably better off seeing the bare bones version of the site anyway.

两相知 2024-07-29 06:04:34

我没有确切的答案,也从未亲自尝试过,但您可以尝试查看移动设备浏览器文件< /a>. 它针对的是开发移动应用程序的 ASP.Net 开发人员,但如果您不这样做,可能仍然有用。 它是开源的并在 MS-PL 下获得许可。

如果您使用的是 ASP.Net,请尝试查看 Scott Hanselman 的播客,了解有关 MDBF 的更多信息 - ASP.Net 和移动网络

I don't have an exact answer and have never tried this myself, but you might try checking out the Mobile Device Browser File. This is targeted at ASP.Net developers working on mobile apps, however may still prove useful if you're not. Its open source and licensed under the MS-PL.

If you are using ASP.Net try checking out this podcast from Scott Hanselman for more info on the MDBF - ASP.Net and the Mobile Web

临走之时 2024-07-29 06:04:34

我建议您查看以下网站:

http://deviceatlas.com/

http://mobileelements.com/

http: //wurfl.sourceforge.net/

它们都讨论如何针对特定的移动设备,这样您就可以针对不同的移动设备使用不同的样式表。

一般来说,对于黑莓,只需在用户代理字符串中查找“blackberry”就足够了

I would recommend checking out the following sites:

http://deviceatlas.com/

http://mobileelements.com/

http://wurfl.sourceforge.net/

They all talk about how you target particular mobile devices, so that way you can use different style sheets for different mobile devices.

Generally for a black berry just look for "blackberry" in the user agent string is a good enough case

黄昏下泛黄的笔记 2024-07-29 06:04:34

这将专门针对 Blackberry 设备,使用名为 blackberry.css 的样式表

var ua = navigator.userAgent;
if (ua.match(/(BlackBerry|Blackberry|blackberry|BB|bb|RIM|rim|Playbook|PlayBook|playbook)/)!=null) { 
     document.write('<link rel="stylesheet" type="text/css" href="blackberry.css">');
     console.log ('Blackberry confirmed'); 
}

This will target Blackberry devices specifically with a stylesheet called blackberry.css

var ua = navigator.userAgent;
if (ua.match(/(BlackBerry|Blackberry|blackberry|BB|bb|RIM|rim|Playbook|PlayBook|playbook)/)!=null) { 
     document.write('<link rel="stylesheet" type="text/css" href="blackberry.css">');
     console.log ('Blackberry confirmed'); 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文