New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Help redirecting to mobile site


Post Reply New Thread Subscribe

 
Thread Tools
bassguy86

 
bassguy86's Avatar
 
Member Since: Feb 07, 2010
Posts: 58
bassguy86 is on a distinguished road
Mac Specs: MacBook Black 2.4 GHz Intel Core 2 Duo, 4GB 667 MHz DDR2 SDRAM 320gb 7200rpm HDD Snow Leopard

bassguy86 is offline
I have a portfolio site and am wanting to make it auto detect and redirect to the mobile version. I have a mobile version created but I am having trouble understanding how to do this. Any help is appreciated.

Check out some of my Design work.
www.jonnypye.com
QUOTE Thanks
DenAtTheDBM

 
Member Since: Nov 29, 2010
Location: Vancouver, BC, Canada
Posts: 27
DenAtTheDBM will become famous soon enough
Mac Specs: Black 13.3" MacBook 4,1 Intel Core2 Duo, 4Gigs Ram (2x2G), 2.4GHz, OS X 10.7.2

DenAtTheDBM is offline
Code:
<script type="text/javascript">// <![CDATA[
 var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
 if (mobile) { document.location = "http://www.youtube.com";}
// ]]></script>
The above code should redirect a mobile browser to youtube. So, just replace the youtube url with the url of your mobile site.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,352
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
If the above doesn't work, there's always the wonderful MooTools Browser class (see here) that can detect platform.

Take a look at this page I created a while back. All it does is print back some info about the browser and platform of the user using MooTools. It doesn't redirect but it does show how easy it is to use MooTools to do basic detection. Feel free to take what you need from the source.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
bassguy86

 
bassguy86's Avatar
 
Member Since: Feb 07, 2010
Posts: 58
bassguy86 is on a distinguished road
Mac Specs: MacBook Black 2.4 GHz Intel Core 2 Duo, 4GB 667 MHz DDR2 SDRAM 320gb 7200rpm HDD Snow Leopard

bassguy86 is offline
Quote:
Originally Posted by DenAtTheDBM View Post
Code:
<script type="text/javascript">// <![CDATA[
 var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
 if (mobile) { document.location = "http://www.youtube.com";}
// ]]></script>
The above code should redirect a mobile browser to youtube. So, just replace the youtube url with the url of your mobile site.
I tried putting in the .mobi version of my site and it gave a "bad gateway" response. Is there a way I could put the path to the mobile folder on my server in the youtube spot and it work?

Check out some of my Design work.
www.jonnypye.com
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,352
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
If you use DenAtTheDBM's solution, you will need to replace the YouTube URL with an appropriate path. How were you trying to do it?

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
bassguy86

 
bassguy86's Avatar
 
Member Since: Feb 07, 2010
Posts: 58
bassguy86 is on a distinguished road
Mac Specs: MacBook Black 2.4 GHz Intel Core 2 Duo, 4GB 667 MHz DDR2 SDRAM 320gb 7200rpm HDD Snow Leopard

bassguy86 is offline
Quote:
Originally Posted by vansmith View Post
If you use DenAtTheDBM's solution, you will need to replace the YouTube URL with an appropriate path. How were you trying to do it?
I was replacing youtube.com with jonnypye.mobi should I use the mobile folder path under jonnypye.com instead? What would that be? index/mobile I would guess since the mobile folder is nested in the main directory. [Main folder/mobile]

EDIT: putting the mobile folder path worked! Thanks for the help!

Check out some of my Design work.
www.jonnypye.com
QUOTE Thanks
bassguy86

 
bassguy86's Avatar
 
Member Since: Feb 07, 2010
Posts: 58
bassguy86 is on a distinguished road
Mac Specs: MacBook Black 2.4 GHz Intel Core 2 Duo, 4GB 667 MHz DDR2 SDRAM 320gb 7200rpm HDD Snow Leopard

bassguy86 is offline
Now for a follow up question: Is there a way to put a link to full site that will bypass the auto redirect?

Check out some of my Design work.
www.jonnypye.com
QUOTE Thanks

Post Reply New Thread Subscribe


« Building a wordpress homepage & blog | Can 8 transfer Aperture 3 photo info to web site photo? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Mac app to create local web site search? David Winter Web Design and Hosting 0 10-10-2011 08:38 AM
Vudu avoids Apple rev share split with iPad mobile site OneMoreThing... Apple Rumors and Reports 0 08-10-2011 07:20 AM
First-ever Macworld Mobile to be held at 2011 Mobile World Congress the8thark Apple Rumors and Reports 0 09-07-2010 03:12 PM
Mobile Site? therichad Community Suggestions and Feedback 1 08-11-2009 04:53 PM
HELP I'm trying to clean out old web site files from server bluerose Web Design and Hosting 8 02-16-2005 10:42 PM

All times are GMT -4. The time now is 11:11 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?