Jump to content

Redirecting mobile traffic to mobile site- Which method?

Hazy125

First of all, this is a personal project, so I'm after what is going to be the best option, not what is the quickest. I want to detect a mobile browser and redirect them to a mobile site. I've seen a few possible ways to do this, but since this is one of the few things I've never looked at before, I want to seek advice from you guys.

First solution

<link rel="stylesheet" href="screen.css" media="screen"/> <link rel="stylesheet" href="handheld.css" media="handheld"/>

I'm not sure about this method, it appears like I'll have to re-use a lot of assets, but it should work still.

 

Second

<script>    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));    var refUrl = document.referrer;    var prevUrl = refUrl.substr(7,16);         var mobileUrl = "m.azharkamar.com";       if ((mobile) && !(prevUrl == mobileUrl)) {        document.location = "http://m.azharkamar.com";    } </script>

Something like this, or a variant of this. This seems like a great way of doing it, but I worry it might not be completely accurate as to what it might redirect

 

Third option

<script type="text/javascript"><!--if (screen.width <= 699) {document.location = "YOUR-MOBILE-SITE.com";}//--></script>

This also seems woefully inaccurate, especially with newer devices and phablets etc.

 

I could also implement something from this site as well http://detectmobilebrowsers.com/

 

I'm hoping to have a solution that automatically updates when a new browser version gets released and such, I will probably have access to PHP(But not yet) as well as the JQuery plugin, maybe another serverside language. If anyone can help or has the definitive answer, please let me know.

 

Cheers

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

Link to comment
Share on other sites

Link to post
Share on other sites

You could also implement a responsive design.

http://en.wikipedia.org/wiki/Responsive_web_design

Ah yes, I considered doing something like this, but I think I would have 2 tailor made sites than 1 all-purpose. For the time being at least, but I did seriously consider going down this route

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

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

×