Solved

jQuery Detect Android

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

Technology Partners: 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!

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.
Here, we have shared an easy step by step tutorial on how to download instagram images and videos on PC, Android Mobile and iOS mobile.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

733 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