Solved

jQuery Detect Android

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

708 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

17 Experts available now in Live!

Get 1:1 Help Now