Solved

jQuery Detect Android

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

825 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