Solved

jQuery Detect Android

Posted on 2010-11-29
5
3,701 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now