1st Sep 2011, 01:32 AM | #1 |
Location Independent War Room Member Join Date: 2011 Location: Bangkok, Thailand
Posts: 411
Thanks: 99
Thanked 83 Times in 55 Posts
|
Hey, I'm trying to improve on my mobile redirection code.. This is what I have so far.. Code: <script> (function mobileRedirect(a,b){ if(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))){ window.location=b; } })(navigator.userAgent||navigator.vendor||window.opera,'http://m.yourmobilesitelink.com'); </script> It seems there isn't one definitive way to do this :rolleyes: |
Living in SE Asia.. BKK.. PM me for a beer! | |
The Following User Says Thank You to Joe Motion For This Useful Post: |
1st Sep 2011, 03:33 AM | #2 |
HyperActive Warrior War Room Member Join Date: 2010
Posts: 145
Thanks: 3
Thanked 24 Times in 17 Posts
|
This one is a very simple one: Code: <script type="text/javascript"> if (screen.width < 800) window.location.replace('mobile.htm'); </script> |
1st Sep 2011, 03:54 AM | #3 |
I think I'm getting there War Room Member Join Date: 2005 Location: West Midlands, United Kingdom.
Posts: 1,959
Thanks: 1,244
Thanked 378 Times in 326 Posts
Blog Entries: 6 |
I can test the redirection right now, as I have my phone by the PC. What website link should I look at. Brian |
Looking For Top Amazon Keywords? Look no further NO CHARGE ;-)
| |
1st Sep 2011, 03:56 AM | #4 | |
Location Independent War Room Member Join Date: 2011 Location: Bangkok, Thailand
Posts: 411
Thanks: 99
Thanked 83 Times in 55 Posts
|
Extremely simple! This is another version of the first one I posted.. Code: <script> var visitorDevice = function() { //return /(iphone|ipod|ipad|android|blackberry|windows ce|palm|symbian)/i.test(navigator.userAgent); //// use the above line of code instead of the one below if you wish to redirect ipad users to the mobile site return /(iphone|ipod|android|blackberry|windows ce|palm|symbian)/i.test(navigator.userAgent); }; if(visitorDevice){ window.location="http://m.yourmobilesitelink.com"; } </script> I'm not 100% on this second one so stick with the first one for now.
I'm currently testing a PHP version.. great for sites based on Wordpress as the PHP runs without any issues and you can simply insert it into header.php and it will forward every single page. | |
Living in SE Asia.. BKK.. PM me for a beer! | ||
1st Sep 2011, 04:36 AM | #5 |
I think I'm getting there War Room Member Join Date: 2005 Location: West Midlands, United Kingdom.
Posts: 1,959
Thanks: 1,244
Thanked 378 Times in 326 Posts
Blog Entries: 6 |
The next piece of the puzzle would be mobile templates. Brian |
Looking For Top Amazon Keywords? Look no further NO CHARGE ;-)
| |
1st Sep 2011, 07:33 AM | #6 | |
Digital Marketer War Room Member Join Date: 2010 Location: Australia
Posts: 12,475
Thanks: 1,984
Thanked 8,187 Times in 4,079 Posts
|
Using javascript is fine so long as you also have a message for those people who are not using javascript. | |
| ||
2nd Sep 2011, 09:56 PM | #7 |
Location Independent War Room Member Join Date: 2011 Location: Bangkok, Thailand
Posts: 411
Thanks: 99
Thanked 83 Times in 55 Posts
|
Looks like I'll stick with my standard JavaScript code then.. Did some research and the amount of people that don't have JavaScript enabled is extremely small.. this is some data I found online from a site that gets 30,000 visitor per month.. JS 1.3 - 94.23% JS 1.2 - 5.61% JS 1.1 - < .00% Other versions - .04 No JS - .12% |
Living in SE Asia.. BKK.. PM me for a beer! | |
3rd Sep 2011, 01:41 AM | #8 |
Lurking Warrior War Room Member Join Date: 2010 Location: Austin, TX
Posts: 264
Thanks: 121
Thanked 92 Times in 78 Posts
Blog Entries: 1 |
Nice! I was about to purchase a full mobile WSO just for that script *lazy*. Thanks for sharing. Do you guys know of any good resources for templates?
|
| |
3rd Sep 2011, 10:06 AM | #9 |
Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 237
Thanked 1,377 Times in 676 Posts
|
I would use a redirect script based simply on browser width, because if your script is based on user agent, then you're going to have to constantly tweak it whenever a new mobile phone or OS comes out. But instead of using a width of < 800, I would use < 1024. Reason being is that there are more than a few smartphones out now that have screen widths greater than 800 (and no doubt many more to come). Yet virtually no one on a regular computer or laptop uses a screen resolution of less than 1024x720 anymore --> Browser Display Statistics Heck, even my tiny netbook has a screen width of 1024 px. |
| |
8th Oct 2011, 10:44 PM | #10 | |
Digital Marketer War Room Member Join Date: 2010 Location: Australia
Posts: 12,475
Thanks: 1,984
Thanked 8,187 Times in 4,079 Posts
|
| |
| ||
9th Oct 2011, 12:05 AM | #11 |
Location Independent War Room Member Join Date: 2011 Location: Bangkok, Thailand
Posts: 411
Thanks: 99
Thanked 83 Times in 55 Posts
|
That's like saying you should forward laptop users that are using 3G users to a mobile site. I'm using a 3G connection on a laptop now actually - and if I was forwarded to a mobile site I'd be annoyed. The main problem is the mobile web is comparatively new and making these decisions is always going to annoy some users. Perhaps someone needs to do a big survey.. but for now I'm forwarding iPad users to the fully functional site. Thanks! |
Living in SE Asia.. BKK.. PM me for a beer! | |
9th Oct 2011, 03:17 AM | #12 | |
Mobile Warrior War Room Member Join Date: 2011 Location: UK
Posts: 190
Thanks: 616
Thanked 205 Times in 134 Posts
|
Neil B | |
| ||
9th Oct 2011, 03:47 AM | #13 | |
Mobile+WP = JumpMobi.com War Room Member Join Date: 2009 Location: San Antonio, Tx
Posts: 1,270
Thanks: 301
Thanked 449 Times in 309 Posts
|
We don't use user agent detection just for redirection purposes like most other people do - we take user agent detection to the next level and use it to deploy and format the correct content to the end users device, as already pointed out just on this thread alone there isn't a one solution fits all, but using php user agent detection like we do gets you very close and certainly gives you the most flexibility if deployed correctly. Unlike everyone else we use a unique approach that filters the user agent data - where possible we look at the device manufacturer, os, phone model and browser type and filter the devices categorizing them into smartphones, non smartphones, non mobile devices and tablets which allows us to deploy the most compatible content for the device accessing our sites - our approach was developed specifically to be super light weight and work at lightening speed so there is no problem with performance. We did use a simplified version of this approach in one of our recent wordpress mobile redirect plugins and are currently testing our approach with a full on mobile wordpress theme. You might ask why go to to all this trouble... Let's just say mobile web development isn't something i just started doing in the past 6 months, I have been working with mobile content passionately for more than 8yrs now - I love mobile! Lol Just like "I got it" and understood the potential of mobile back then it's just taken time for technology to catch up and every day people "to get it" more importantly corporate is now starting "to get it" too, this mobile platform is just going to get bigger and we are embracing it now just like some warriors are improving their own scripts or mobile platforms/services for better functionality and service its because like them we see the bigger picture... | |
Sorry, I am too busy helping people to think of a cool signature! | ||
9th Oct 2011, 09:57 AM | #14 |
Warrior Member War Room Member Join Date: 2010 Location: Here and there
Posts: 3
Thanks: 1
Thanked 1 Time in 1 Post
|
Thanks for that post, Do you do any teaching or have a small course. With 8 years I'm sure you have some good tricks. Tom |
9th Oct 2011, 12:52 PM | #15 | |
Mobile+WP = JumpMobi.com War Room Member Join Date: 2009 Location: San Antonio, Tx
Posts: 1,270
Thanks: 301
Thanked 449 Times in 309 Posts
|
Doing training is something i have considered, unfortunately time is really the restricting factor. I am currently rolling out products that will enable people to hit the ground running with mobile. All of the products we launch are based around my own experience and vision towards deploying mobile which will hopefully help people avoid many of the pitfalls i have had to already work around. I always encourage people to think out of the box and perhaps my solutions are not for everyone but at least it can perhaps give people a much wider insight to mobile and avoid some of the pitfalls i have come across in the past. Also with better understanding of where i am coming from with my approach it may stop people thinking i am crazy but instead give them a better understanding why i feel so passionate about what i do and perhaps give them reason to be inspired enough to get involved and share in the experience! | |
Sorry, I am too busy helping people to think of a cool signature! | ||
9th Oct 2011, 01:03 PM | #16 |
HyperActive Warrior War Room Member Join Date: 2003
Posts: 126
Thanks: 55
Thanked 66 Times in 35 Posts
|
I've gone to sites on my iPhone that have given me a pop-up/pop-out message saying "It appears you're on a mobile device, would you like to go to our mobile site?" How do I do this? |
I think Lime Cellular is the best white label SMS marketing platform. | |
9th Oct 2011, 01:09 PM | #17 | |
Mobile+WP = JumpMobi.com War Room Member Join Date: 2009 Location: San Antonio, Tx
Posts: 1,270
Thanks: 301
Thanked 449 Times in 309 Posts
|
i have stopped deploying that on new sites for the interim period as i have a much better approach that uses cookies to stop it continually popping up if you cancel | |
Sorry, I am too busy helping people to think of a cool signature! | ||
Bookmarks |
Tags |
code, mobile, redirection |
| |