Coder
Coder

Reputation: 253

How to identify the blackberry's browsers

I should identify whether the site is accessed by mobile or web. I am using $_SERVER['HTTP_USER_AGENT'] to identify this. Based on that am loading mobile site.

Everything works fine.

My Problem is, If I change the browser settings in blackberry, from blackberry to Firefox or IE, then it is loading the normal site instead of mobile site.

How to overcome this problem? Please help.

NOTE : Am checking in Blackberry 5

Upvotes: 0

Views: 118

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385274

You cannot. You are completely dependent on the browser to tell you what it is. User-agent spoofing blasts that "trust" out of the water.

Instead, you can do "functional" tests in Javascript/CSS that provide features for supporting browsers and fallback mechanisms for non-supporting browsers.

But if you want to switch to a mobile site then you really do just have to do as the browser asks. That's the server's job, anyway; if the user has gone out of their way to pretend that their phone is a normal PC, then that's their choice and your server should just do as it's told.

This is why the option exists in the Blackberry browser in the first place.

As an example, I sometimes find myself making my Android browser spoof itself as Firefox on Windows, so that I can use the normal Facebook site and access features that Facebook haven't implemented on their mobile version.

Upvotes: 3

Related Questions