Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
* * * * * 1 votes

Check For Mobile Browser


12 replies to this topic

#1 Tramposch

    Kyle_vdk

  • KS GFX Crew
  • PipPipPipPipPipPipPipPipPip
  • 921 posts
  • Gender:Male
  • Location:Richmond, Virginia, United States
  • myCENT:93.1
  • T17 GFX Crew

Posted 07 January 2009 - 03:43 AM

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!

#2 rpgsearcherz

    Trap Double Mocha Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 2,025 posts
  • Gender:Male
  • Interests:Working on my Rift fansite
  • myCENT:56.86
  • Spam Patrol

Posted 07 January 2009 - 04:20 AM

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.

#3 Echo_of_thunder

    Trap Grand Marshal Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,239 posts
  • Gender:Male
  • Location:New Jersey USA
  • Interests:Weather of all kinds, be it a tornado, thunderstorm, hurricane, snowstorm. Give it all to me!
  • myCENT:50.97
  • Spam Patrol

Posted 07 January 2009 - 04:27 AM

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.

#4 Tramposch

    Kyle_vdk

  • KS GFX Crew
  • PipPipPipPipPipPipPipPipPip
  • 921 posts
  • Gender:Male
  • Location:Richmond, Virginia, United States
  • myCENT:93.1
  • T17 GFX Crew

Posted 07 January 2009 - 04:42 AM

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.

#5 sonesay

    |||[ n00b King ]|||

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 958 posts
  • Gender:Male
  • Location:Auckland
  • myCENT:68.27

Posted 07 January 2009 - 05:35 AM

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.co...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, 07 January 2009 - 05:46 AM.


#6 ragav.bpl

    Premium Member

  • Kontributors
  • PipPipPipPipPipPipPipPip
  • 175 posts
  • Gender:Male
  • Location:Computer World
  • myCENT:61.56

Posted 07 January 2009 - 08:16 PM

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

#7 Tramposch

    Kyle_vdk

  • KS GFX Crew
  • PipPipPipPipPipPipPipPipPip
  • 921 posts
  • Gender:Male
  • Location:Richmond, Virginia, United States
  • myCENT:93.1
  • T17 GFX Crew

Posted 08 January 2009 - 08:10 PM

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!

#8 Antv912

    Member [Level 1]

  • Kontributors
  • PipPipPipPip
  • 61 posts
  • Gender:Male
  • Location:http://
  • myCENT:23.24

Posted 25 January 2009 - 08:44 PM

This may help - http://mobile.phpmagazine.net/ and good luck on your website.

Edited by Antv912, 25 January 2009 - 08:44 PM.


#9 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 20 November 2009 - 02:35 PM

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://modules.Apach...rch.Php?id=1787) that detect mobile device and also can adapt the images to the screen size of device.For more info: http://www.idelfusch...filter-v2x.html

-reply by Idel

 



#10 onkarnath2001

    Member [Level 3]

  • Kontributors
  • PipPipPipPipPipPip
  • 92 posts

Posted 21 November 2009 - 02:15 AM

View PostTramposch, on Jan 7 2009, 09:13 AM, said:

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




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users