javascript - User agents for iOS - ipad, iphone, ipad is false while it should be true -


i'm using user agent check whether visiting user coming ipad or iphone.

im using following check so:

var isiosapp = false; var isios_ipad; var isios_ipod; var isios_phone;  /* detect if running on ios */ function getmobileoperatingsystem() {   var useragent = navigator.useragent || navigator.vendor || window.opera;    if( useragent.match( /ipad/i ) || useragent.match( /iphone/i ) || useragent.match( /ipod/i ) )   {     return 'ios';    }   if( useragent.match( /ipod/i ) )   {     return 'iosipod';    }   if( useragent.match( /ipad/i ) )   {     return 'iosipad';    }   if( useragent.match( /iphone/i ) || useragent.match( /ipod/i ) )   {     return 'iosphone';    } }  if(getmobileoperatingsystem() == "ios") {     isiosapp = true; } if(getmobileoperatingsystem() == "iosipod") {     isios_ipod = true; } if(getmobileoperatingsystem() == "iosipad") {     isios_ipad = true; } if(getmobileoperatingsystem() == "iosphone") {     isios_phone = true; } 

when visiting both ipad , iphone following:

isiosapp = true isios_ipad = undefined isios_phone = undefined isios_ipod = undefined 

so seems triggered in first if condition.

what going wrong since none of individual devices isios_ipad isios_phone isios_ipod turning = true?

you think atleast 1 should = true isiosapp trigger = true


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -