Welcome to TalkGraphics.com
Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20
  1. #11
    Join Date
    Jan 2011
    Posts
    1

    Default Re: Mobile optimized sites

    Hi All,

    In order to redirect the mobile browser to the mobile optimized version of the website there are 2 main ways.
    1. You can either use Javascript but not all mobile phone support that.
    2. Redirect the visitor using the ".htaccess file". It is the usual way and it works in most cases.

    Cheers,
    Csaba

  2. #12
    Join Date
    Sep 2010
    Location
    Dallas, TX
    Posts
    14

    Default Re: Mobile optimized sites

    I have never really messed too much with the ".htaccess file," would you be able to clarify the method?

    Thank you

  3. #13
    Join Date
    Jan 2011
    Location
    Geneva, Switzerland
    Posts
    64

    Default Re: Mobile optimized sites

    Detection in HTML and JavaScript is possible. No need for PHP

    Here is an example for the iPhone. It looks for the "iPhone" word in the browser header. Of course you should know the other signatures from Blackberry, WindowsMobile, etc... to make it universal.

    This example asks the user whether s-he wants to be redirected, but the question itself can be skipped.


    Code:
    <script type="text/javascript">
    
    function iPhoneAlert() {
    	if((navigator.userAgent.match('iPhone'))){
    		var question = confirm("Would you like an iPhone optimized version of the website??")
    		if (question){
    			window.location = "http://mywebsite.com/mobile";
    		}else{
    			window.location = "http://mywebsite.com";
    		}
    	}
    }
    </script>
    
    <body onLoad="iPhoneAlert();">

  4. #14
    Join Date
    Jul 2009
    Location
    Nashville - Murfreesboro TN
    Posts
    69

    Default Re: Mobile optimized sites

    Is there a similar java script that will automatically redirect to the normal site (desktop site) for IPADS? I am using Network Solutions and Mobeezo. They both provided this switching code that sends my mobile visitors to mobile devices:

    Here is the line I am using now: <script type="text/javascript" src="http://detect.deviceatlas.com/redirect.js?d=http://www.mymainwebsite.com&m=http://mymobilewebsite.com">
    </script>


    The only problem is it sends I-PAD users to the mobile site as well.

  5. #15
    Join Date
    Jan 2011
    Location
    Geneva, Switzerland
    Posts
    64

    Default Re: Mobile optimized sites

    If I'm correct, look for "iPad".
    The user agent from my iPad is

    Code:
    Mozilla/5.0 (iPad; U; CPU OS OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10
    So just ignore any redirection if you get iPad (check in lowercase or uppercase to make sure you get the thing in any case)

  6. #16
    Join Date
    Jul 2009
    Location
    Nashville - Murfreesboro TN
    Posts
    69

    Default Re: Mobile optimized sites

    Huh? I do not understand the line of code.

    How would I modify the code in your previous post for IPhones to IPads? And have it skip the question "Would you like an iPad optimized version of the website?"

    Thank you for your help.
    Last edited by Dirtwad; 04 September 2011 at 06:36 AM. Reason: Incomplete

  7. #17
    Join Date
    Jan 2011
    Location
    Geneva, Switzerland
    Posts
    64

    Default Re: Mobile optimized sites

    Not that I know of.
    My guess is that everythign has to be decided at the entry point of your web site.

    Everything goes to the normal web site as long as the device is not in a specific list.
    In that case you then redirect.

    That's what I do: what is the user agen (the only way to get an idea about the device connecting to your web site). If it contains "iPhone", then, and only in that case, redirect to a mobile version. Otherwise, continue normally.
    "iPad" would not trigger a redirection since it's not equal to "iPhone".

    Or you can have three version of your site:
    user agent = iPhone? -> small screen version
    user agent = iPad? -> 1024x768 screen version
    otherwise -> normal version

    But this will not solve another potential problem: screen orientation. If you design a 1024x768 web site version for the iPad, it will look fine as long as the user handles his/her iPad in landscape. As soon as s/he rotates it to portait, then the website will be resized.

  8. #18

    Default Re: Mobile optimized sites

    in Apache servers, you can use .htaccess to redirect based on device

  9. #19
    Join Date
    Jul 2009
    Location
    Nashville - Murfreesboro TN
    Posts
    69

    Default Re: Mobile optimized sites

    Thank you all for your help. Techmedia please advise the line of code that applies to Ipad devices. I am using Linux/Apache servers. THe switching code that I am using works fine except it sends Ipad users to the mobile website.

    Here is the code: <script type="text/javascript" src="http://detect.deviceatlas.com/redirect.js?d=http://www.mymainwebsite.com&m=http://mymobilewebsite.com">
    </script>

    Thoughts?

  10. #20
    Join Date
    Sep 2011
    Posts
    3

    Default Re: Mobile optimized sites

    The absolute best solution for automatically redirecting mobile device visitors from a "desktop" website to their mobile site can be found at http://www.handsetdetection.com. They offer a totally free account with up to 10,000 hits per month (I think). It's plenty, at any rate. And you can log in to see statistics! Best of all, there's no catch.

 

 

Bookmarks

Posting Permissions

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