How can I detect kindle fire with javascript?

gabitzish picture gabitzish · Jan 30, 2012 · Viewed 10.1k times · Source

I'm trying to detect with javascript if my website is running on a kindle fire mobile device. I've tried with navigator.userAgent and navigator.appVersion but I get this results on kindle :

5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16

and

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16

What can I use form those strings to know that I'm on a kindle and not on other device?

Answer

Venkat Reddy picture Venkat Reddy · Jan 9, 2014

in Javascript ,

var ua = navigator.userAgent;
var isKindle = /Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua);
if(isKindle) { 
//Your code here
}