Welcome to TalkGraphics.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2011
    Posts
    13

    Default Mobile site autodetect

    I have a mobile site hosted with a different server site than my main website. Is there a script that I can insert into my main site (which was built using Web Designer MX Premium) that will autodetect a mobile browser and redirect to the mobile site. I'm not a programmer, so it needs to be easy to do and will work with a Web Designer site. Any suggestions?

  2. #2
    Join Date
    Jan 2010
    Location
    Bradford, England
    Posts
    1,829

    Default Re: Mobile site autodetect

    Either create a placeholder and name it <head> or pop the following code into the head section through web properties:

    <script type="text/javascript">
    <!--
    if (screen.width <= 699) {
    document.location = "mobile.html";
    }
    //-->
    </script>

    Change the red text to the url of your mobile site so for instance www.yoursite.com/mobile.htm

    This works with all devices with a lower than 699 screen width (you can change this)

    Or you can use the code specific to apple devices

    <script language=javascript>
    <!--
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    location.replace("http://url-to-send-them/iphone.html");
    }
    -->
    </script>

    Again just replace the red url text with your domain
    Flawless Form. Faultless Function. Crafted by Cloud

    https://www.cloudwebagency.co.uk

  3. #3
    Join Date
    Sep 2011
    Posts
    13

    Default Re: Mobile site autodetect

    Awesome, thank you!

  4. #4
    Join Date
    Sep 2011
    Posts
    13

    Default Re: Mobile site autodetect

    One other question about this, does it need to be inserted just on the home page, or in all the pages on the site, in the event that someone clicks in from a search result to a page other than the home page?

  5. #5
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,535

    Default Re: Mobile site autodetect

    Unless people are coming to specific pages within your site, I would think just the home page. But to be sure, and you'll need to use the placeholder named <html> method, you can copy and paste the placeholder on all pages.

 

 

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
  •