Solved

How do we get the browser to switch to a mobile version of our site when using a mobile phone?

Posted on 2014-03-06
7
191 Views
Last Modified: 2014-03-08
I have a site, that we would like to switch to a mobile version when users viewing from a mobile browse on phones.  looking for info on how to do this
0
Comment
Question by:bmanmike39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39910997
You need to design a responsive version of your site or build a mobile version of your site that will only show on mobile devices
Multiple frameworks are available for designing a responsive site like Bootstrap
0
 

Author Comment

by:bmanmike39
ID: 39911007
I know that,  How do we make it switch over or detect if its a mobile device or not?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39911024
A responsive website does that automatically based on CSS media queries.
If you are designing a separate mobile site then you need to use javascript to detect the browser/device and redirect to the mobile version
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39911028
Ideally, you don't detect mobile. You simply design a site that will adjust itself according to the measurements of the viewport. Frameworks like Bootstrap will do this for you automagically. In the very worst case, you rely on user-agent detection, but this is unreliable and a brittle design. Stick with a framework that yields a responsive design. There might be a learning curve, but it will often be less work in the end.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39911379
My customer chose this method based on screen size to give them a choice.  A lot of 'mobile' devices have screens large enough to use the desktop sites.
<script type="text/javascript">
<!--
var t1=screen.width;
var t2=screen.height;
var t5=screen.availWidth;
var t6=screen.availHeight;
function myFunction()
{
if(t1 < 484 || t2 < 484) {
	var r=confirm("We have an alternate view for smaller screens.  Would you like to try it?");
	if (r==true)
  	{
	  window.location.assign("http://www.yoursite.mobi/")
  	}
	}
}


// -->
</script>
</head>
<body onload="myFunction()">

Open in new window

0
 

Author Closing Comment

by:bmanmike39
ID: 39915293
Thanks!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39915403
You're welcome.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question