Reputation: 440
I tried to run this following code
var uagent = navigator.userAgent.toLowerCase();
if (uagent.search("iphone") > -1)
alert("true");
else
alert(uagent);
and getting above output, even when i choose iphone for simulation
why does this happens?
Upvotes: 1
Views: 66
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