Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Mobile Browsing

  1. #1
    New Coder
    Join Date
    Jan 2011
    Location
    Space
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Mobile Browsing

    I was thinking of making a mobile optimized version of my website but I'm stuck on how the site can tell if it's a mobile device that's browsing, I assume it would be similar to the standard browser IF like:
    Code:
    <!--[if IE]>Things here.<![endif]-->
    So i was just wondering what I would use to make it recognize a mobile browser and if there was a few codes for certain devices such as iPad and Android.
    Last edited by Celestial; 06-22-2011 at 02:29 AM. Reason: Resolved.

  • #2
    New Coder
    Join Date
    Jan 2011
    Location
    Space
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lightways View Post
    no i think that could not be possible in mobile phones
    It is... And thank you for all those pointless links.

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    California
    Posts
    201
    Thanks
    30
    Thanked 8 Times in 8 Posts
    stick this into your root .htaccess file

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
    RewriteRule ^ - [CO=mredir:0:www.example.com]
    RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
    RewriteCond %{HTTP:Profile}       !^$ [OR]
    RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
    RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]
    RewriteCond %{HTTP_HOST}          !^m\.
    RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) 
    RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]
    RewriteRule ^ http://www.example.com/mobile [R,L]
    change www.example.com on Line 4 to your domain name. On the last line, change to your mobile website! Anytime someone views your site from a mobile device they will be forwarded to the domain name you specify on the last line!
    Last edited by eberdome; 06-21-2011 at 06:51 AM.
    "The problem with troubleshooting is that trouble shoots back."

  • Users who have thanked eberdome for this post:

    Celestial (06-22-2011)

  • #4
    New Coder
    Join Date
    Jan 2011
    Location
    Space
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by eberdome View Post
    stick this into your root .htaccess file

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
    RewriteRule ^ - [CO=mredir:0:www.example.com]
    RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
    RewriteCond %{HTTP:Profile}       !^$ [OR]
    RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
    RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]
    RewriteCond %{HTTP_HOST}          !^m\.
    RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) 
    RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]
    RewriteRule ^ http://www.example.com/mobile [R,L]
    change www.example.com on Line 4 to your domain name. On the last line, change to your mobile website! Anytime someone views your site from a mobile device they will be forwarded to the domain name you specify on the last line!
    There appears to be a problem with this code, the site gets stuck on a loop of refreshes from it and I can't work out why. Any help?

  • #5
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    No, browser sniffing is an awful, outdated way to do this.

    You may provide mobile CSS by using this media query:

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

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    there is special meta for ios devices. many of the same also work on android.
    till, these are mostly for decorating shortcuts, except for the scaling markup; it's important to nail for a proper user experience. needless scrolling makes mobile suck.

    use special css for mobile and sniff mobile stuff in js using tools like modernizer or ad-hoc detection.


    scale back on image use; its cost user's money and slows down the page considerably.
    you can clobber any existing background-image urls using more specific selectors to declare background:none; ...

    emphasize features of the site that are likely to be used by someone on a small screen or in an on-the-go situation. for example if you're an organization, don't blather about your history on the landing page, throw a menu in my face, preferably something that offers simple single word options like [news, events, search, sections, about]...


    bottom line: you don't have as much room to look pretty or do fancy stuff.
    people don't want that. they want to get in and out as quickly as possible cause it a PITA using a mobile browser. the less painful you make it, they more they will love you.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •