1

I am Getting false value when i check my device is iPad, How can I do that; can any one help me. I've provided code below which can help.

var isiDevice = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()); if (isiDevice) { CallFullScreen(); } 

4 Answers 4

2

Try this

 if( !navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/webOS/i) && !navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/BlackBerry/i) ) { you code goes here for samll device like iphone, androide. } 
Sign up to request clarification or add additional context in comments.

Comments

1

you can use the below code in if condition for detecting device

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // do somethig } 

Comments

1

use below script which allow to detect many device. this script allow you to detect single or multiple device browser

 var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPod|ipad/i); }, ipad : function(){ return navigator.userAgent.match(/iPad/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, BB: function() { return navigator.userAgent.match(/BB10/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || isMobile.BB()); } }; call like below if(isMobile.any()) // this function gives if any mobile browser if(isMobile.ipad()) // return if ipad 

Comments

1

Try this :

var isiDevice = navigator.userAgent.match(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i) != null; if (isiDevice) { CallFullScreen(); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.