Jump to content
xisto Community
Tramposch

Check For Mobile Browser

Recommended Posts

I want to create a mobile version of my website, and I need to know how to check for mobile browsers. I am thinking of creating an iPhone specific one too. I looked around and all I really found were shaky solutions that didn't check very well. I think that PHP would be the best language to check, as it is pretty universally supported, however, if there is a more efficient way to check in another language then please tell me!

Share this post


Link to post
Share on other sites

I think most "mobile" websites have two versions, of which the mobile one would use a different link. Instead of "checking" to see if it's mobile, the user would have to manually use the other address.For example, with Gmail there is gmail.com and the other is mobile.gmail.com I think. Or it's something like that.

Share this post


Link to post
Share on other sites

I seem to remember when I was dealing with my site something about google mobil and RSS files for mobile phones. if that is any help to ya.

Share this post


Link to post
Share on other sites

I will have a dedicated address for it, too, but I also want it to check for the mobile browsers and direct it to the mobile site or at least a page to choose whether or not to go to the mobile site. That way if somebody doesn't know there is a mobile version, they have the chance to learn about it.

Share this post


Link to post
Share on other sites

If you are using PHP then you can use the session variable (I think thats what its called) $_SERVER['HTTP_USER_AGENT']. This will return a string with various values depending on the user agent of the client.

Now you just need to code what type of broswers your looking for and since its mobile broswers your after heres a list of user agents so far. http://www.zytrax.com/tech/web/mobile_ids.html

Use preg_match() to check and redirect as needed.

heres a sample of my code below. I think yours will have to be much longer to include all mobile browsers. That is if you want to check for all right?

$ua = $_SERVER['HTTP_USER_AGENT'];$pattern = "/msie\s(5\.[5-9]|6\.[0-9])/i";if(preg_match($pattern,$ua)){	header("location: redirect.php");}

edit: I'm not sure if preg_match can take arrays as the pattern, if it can then you can setup an array of all those broswer strings. easy :P.

Update:***

Actually someone has already written some code for this. http://detectmobilebrowsers.mobi/ I think this would be alot easier then trying to preg_match all on your own. GL
Edited by sonesay (see edit history)

Share this post


Link to post
Share on other sites

Yes i also suggest that if u can check the browser id and match it with the mobile site you want to load. In simple programming language just get some mobile ids and use a if statement for each id. Say for eg if u a user comes to your site via opera mini then t just check his id and match it with the site u optimized with opera and start that page. Thats all hope i helped

Share this post


Link to post
Share on other sites

Thanks for the help guys. I am going to try the effectiveness of those methods. I will probably check out that site sonesay mentioned. Now I just need to build the sites...Woohoo!

Share this post


Link to post
Share on other sites
Apache Mobile FilterCheck For Mobile Browser

I have published a new mode to detect devices in any programming language (JSP, PHP, Perl, Python...), it's called Apache Mobile Filter is an Apache module (http://forums.xisto.com/no_longer_exists/) that detect mobile device and also can adapt the images to the screen size of device.For more info: http://forums.xisto.com/no_longer_exists/

-reply by Idel

 

Share this post


Link to post
Share on other sites

I want to create a mobile version of my website, and I need to know how to check for mobile browsers. I am thinking of creating an iPhone specific one too. I looked around and all I really found were shaky solutions that didn't check very well. I think that PHP would be the best language to check, as it is pretty universally supported, however, if there is a more efficient way to check in another language then please tell me!

i think todays mobile browsers have the enough capability to handle big pages.like opera mini or bolt browser.it can show you the pages as you are watching it in your pc with a minor limitation.only the problem is small screens.
so many times i have made payments and watched online movies also with this bolt browser.so whats the need to make a mobile site fro your web site.any way,if you create it.y dont you make it with m.domain name.your tld (like m.trap17.com) it looks good also and anyone can understand that it is for mobile only.all the best

Share this post


Link to post
Share on other sites
Check for mobile browsers and display alternative websiteCheck For Mobile Browser

Hi, I have created a mobile friendly web page, and want to have that page displayed on mobile devices rather than the normal index page. I have tried some javascript to make the mobile jump to the different page, but it does not work. Any other suggestions. The page is saved as html headed up with WML in dreamweaver.

-reply by bloohair

Share this post


Link to post
Share on other sites

I wrote an article on mobile browser detection and redirection. There are downloadable examples as well as a fully functional example implementation.

Perl - http://www.mlynn.org/2010/07/mobile-device-detection-and-redirection-with-perl-and-cgi/

PHP -
http://www.mlynn.org/2010/06/mobile-device-detection-and-redirection-with-php/

Live Example: http://forums.xisto.com/no_longer_exists/

I hope this helps!

Enjoy,
Mike

Share this post


Link to post
Share on other sites

For my website, I had my brother test it on his iPhone. My very first page is a flash video, which is the introduction and/or [after] you click a button to enter the home page. But my brother says the button wasn't working.So I needed to figure out a way to make Mobile phones automatically be taken to my site:I found a great site that has all the coding information here: http://forums.xisto.com/no_longer_exists/ this helps anyone in search.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.