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

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
bmanmike39Asked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
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
 
GaryCommented:
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
 
bmanmike39Author Commented:
I know that,  How do we make it switch over or detect if its a mobile device or not?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
GaryCommented:
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
 
käµfm³d 👽Commented:
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
 
bmanmike39Author Commented:
Thanks!
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.