Here is a free mobile device detect and redirect script for Warrior Buddies!

by 15 comments
hey buddies,

Just shared this on someone else's thread, but im sure everyone could use it. Its used to detect mobile users on a desktop site and redirect them to a mobile site at a specific URL. Enjoy:

Just copy paste this code in between the <header>...</header> tags on the page you want to detect and redirect. Also change the "http://www.gomobileenterprise.com" to whatever your mobile site URL is.



HTML Code:
<script>
function detect() {
       var uagent = navigator.userAgent.toLowerCase();
       var mobile = false;
       var search_strings = [
           "iphone",
           "ipod",
           "ipad",
           "series60",
           "symbian",
           "android",
           "windows ce",
           "windows7phone",
           "w7p",
           "blackberry",
           "palm"
       ];
       for (i in search_strings) {
           if (uagent.search(search_strings[i]) > -1) mobile = true;
       }
       return mobile;
   }
   if (detect()) window.location = "http://gomobileenterprise.com/";
</script>
#mobile marketing #buddies #detect #device #free #mobile #redirect #script #warrior
  • Profile picture of the author BiggestB
    [DELETED]
  • Profile picture of the author netizen
    [DELETED]
  • Profile picture of the author Mr Bill
    What happens when a mobile visitor wants to see the full size website? Does this force them back to the mobile version in a loop?
  • Profile picture of the author Jay Moreno
    i would disagree php user agent detection in my opinion the best way to redirect visitors thats if you are using php of course, regardless if most phones are running javascript with php user agent detection not one single line of code needs to be rendered for the detection to kick in and redirect reduces overall page load speed - also certain earlier version of Android have issues with javascript screensize detection, there is actually a thread here on WF started by WillR specifically about that if i recall correctly. You will also find that 574px for newer smartphones will be way too low.

    If you want to stick with javascript then why not do both javascript useragent detection and screensize detection... that way you have the best of both worlds.

    FYI for the original script Bonn posted you will also need to add the user agent "bb" if you want the newer blackberries to be detected - since on newer devices the user agent no longer contains the word Blackberry. User agent for more recent Windows phone needs to be added too for the small handful of people using those devices! LOL

    HTH
  • Profile picture of the author Moneymaker2012
    [DELETED]
  • Profile picture of the author heyulin
    many thanks to your share~
    take a try later
  • Profile picture of the author Jay Moreno
    @joe - i use our own redirect plugin for WP but for when i have to use a javascript version on a standard site i typically use this one:

    https://github.com/sebarmeli/JS-Redirection-Mobile-Site

    hth
  • Profile picture of the author Toby Henderson
    P.M. me if you want a Free Mobile Site Builder... I am your real internet buddy notice how many advertisements below... zero yes its Christmas early today and this one comes with the script... I will send you a zip file if you like it which you will just add me as a friend here in the WF. I have built sites out with it and its very easy. It even comes with video setup and redirect and wordpress install or regular site doesn't matter. Your site will pick up mobile users and redirect them to a separate nice looking mobile optimized site... built in php so it passes data and is real quick set up...
  • Profile picture of the author israrahmed
    [DELETED]

Next Topics on Trending Feed