Prasanna
Prasanna

Reputation: 440

why does a simulator returns uagent as ipad even for iphone simulation?

I tried to run this following code

var uagent = navigator.userAgent.toLowerCase();
 if (uagent.search("iphone") > -1)
     alert("true");
 else
      alert(uagent);

 output i got

and getting above output, even when i choose iphone for simulation

why does this happens?

Upvotes: 1

Views: 66

Answers (1)

Williham Totland
Williham Totland

Reputation: 29029

To make a very long story very short:

User agent strings are problematic.

Making assumptions based on the user agent string is even more so.

Mozilla has a reasonably comprehensive article on it here.

Upvotes: 1

Related Questions