Solved

jQuery Detect Android

Posted on 2010-11-29
5
3,708 Views
Last Modified: 2012-05-10
I have a site with a fixed footer. I am using this jQuery fix to make it static for the Iphone and Ipad as well as the Ipod:
//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit
jQuery(document).ready(function ($) {
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
{
     $("#footer").css("position", "static");
};
});

Open in new window


Works well. But what name should I add to add the same fix for Google Android? it has the same issue with viewports and fixed elements, but just adding Android after another || does not seem to work..
0
Comment
Question by:rhandalthor
[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
  • 4
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 34229978
0
 

Author Comment

by:rhandalthor
ID: 34230135
//stick the footer at the bottom of the page if we're on an iPad/iPhone/Android due to viewport/page bugs in mobile webkit
jQuery(document).ready(function ($) {
	var deviceAndroid = "android";
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' || uagent.search(deviceAndroid) > -1)
{
     $("#footer").css("position", "static");
};
});

Open in new window

\

does not seem to work yet or my VirtualBox Android is having some caching issues..
0
 

Author Comment

by:rhandalthor
ID: 34230144
I get a uagent not defined error in FF. But I did define it?!!?
0
 

Author Comment

by:rhandalthor
ID: 34233325
Solved it:
//stick the footer at the bottom of the page if we're on an iPad/iPhone/Android due to viewport/page bugs in mobile webkit
jQuery(document).ready(function ($) {
	//if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/iPod/i)))
{
     $("#footer").css("position", "static");
};

});

Open in new window

0
 

Author Closing Comment

by:rhandalthor
ID: 34233360
Useful link given, but no follow ups. Final solution added by myself.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
There is a lot to be said for protecting yourself and your accounts with 2 factor authentication.  I found to my own chagrin, that there is a big downside as well.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 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