Your Ad Here

Sunday, December 9, 2012

How to set our site mobile landing page

Give mobile visitors a way for redirect to our mobile version :

Getting Started

To make this easy, I have provided a mobile template for you to download, which means that all we will have to do is set up redirects for mobile browsers. You can customize the template landing page however you see fit – it’s just standard HTML/CSS.
Here’s what you need to do to get started:
  1. Download the template file.
  2. Create a directory (or page) to send mobile users to – some common subdomains are “m” or “mobile” (eg. m.digg.com and m.facebook.com).
  3. We will be using JS Mobile Redirection to redirect mobile browsers, the script can be downloaded on GitHub. Place the .js file wherever you choose, I have placed mine in a folder called “js”.

Set the Redirect

On the index page of your site, in the <head> section paste in the following lines:

  1. <script type="text/javascript" src="js/redirection_mobile.min.js"></script>  
  2. <script type="text/javascript">  
  3. SA.redirection_mobile ({param:"isDefault", mobile_prefix : "m", cookie_hours : "1" });  
  4. </script>  
This will send any visitor that arrives on the index page to the subdomain “m.website.com”, but only once every hour. If they press the link on the template page that says “continue to full site”, they will not be redirected within the defined timeframe.
That’s pretty much it. Congratulations, you have a mobile landing page – now go forth and customize.
Note: If you are redirecting to a specific page rather than a subdomain you can do this by including mobile_url : “website.com/mobile” and mobile_prefix : “http”. Refer to the documentation for further explanation.

Additional Notes

Fitting to Screen

You may have noticed the following meta tag in the downloadable files for this tutorial:
view plaincopy to clipboardprint?
  1. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=false;" />  
This is the tag that determines how the page fits to the screen and if a visitor can zoom in and out. Mozilla does a fine job of explaining this in great detail, check out their page on the viewport meta tag for a more rigorous exploration.