"Interesting" mobile browser detection
-
The local electricity company's online management portal seems to use some rather interesting browser detection code:
var isMobile = "" === "true"; var isAndroid = "" === "true"; var isIPad = "" === "true"; var isIPhone = "" === "true";
I went to the site using Google Chrome on my phone (a Samsung Galaxy S3). It rendered with a mobile stylesheet but that isAndroid variable was still false.
At least they're checking for strict equality, right?
-
That chick has crazy-eyes.
-
@mikeTheLiar said:
That chick has crazy-eyes.
Marketing verbage always seems more real when it's in a cartoon balloon coming out of the mouth of a cute chick. https://electricityoutlook.jemena.com.au/
-
-
They're checking for substrings of the UA on the server and writing it into the generated HTML to be able to use it from JS. Presumably Chrome on Android doesn't send in "Android" or whatever the default Android browser sends?
-
@Arnavion said:
They're checking for substrings of the UA on the server and writing it into the generated HTML to be able to use it from JS. Presumably Chrome on Android doesn't send in "Android" or whatever the default Android browser sends?
Why is it so hard for them to output the textfalse
then? You can't explain that!
-
@Ben L. said:
@Arnavion said:
They're checking for substrings of the UA on the server and writing it into the generated HTML to be able to use it from JS. Presumably Chrome on Android doesn't send in "Android" or whatever the default Android browser sends?
Why is it so hard for them to output the textfalse
then? You can't explain that!Because the examineUAStringAndReturnJavascript() function returns "" instead of false. Also it's written in Go so nobody except the guy who wrote it wants to touch it, but he got fired for showing up to a meeting drunk and muttering something about rewriting it to use Redis and AngularJS.
-
@Arnavion said:
@Ben L. said:
@Arnavion said:
They're checking for substrings of the UA on the server and writing it into the generated HTML to be able to use it from JS. Presumably Chrome on Android doesn't send in "Android" or whatever the default Android browser sends?
Why is it so hard for them to output the textfalse
then? You can't explain that!Because the examineUAStringAndReturnJavascript() function returns "" instead of false. Also it's written in Go so nobody except the guy who wrote it wants to touch it, but he got fired for showing up to a meeting drunk and muttering something about rewriting it to use Redis and AngularJS.
Here, let me rewrite it for them:
func examineUAStringAndReturnJavascript() string { log.Print("WHY THE FUCK ARE YOU BROWSER SNIFFING?") os.Exit(1) return "false" }
-
@Ben L. said:
Here, let me rewrite it for them:
Because all browsers have slightly different rendering and they want a consistent look for their website across all platforms?func examineUAStringAndReturnJavascript() string { log.Print("WHY THE FUCK ARE YOU BROWSER SNIFFING?") os.Exit(1) return "false" }
-
@SamC said:
@mikeTheLiar said:
That chick has crazy-eyes.
I also immediately though of Overly Attached Girlfriend. Too much reddit rots your brain...
@Sutherlands said:
@Ben L. said:
Here, let me rewrite it for them:
Because all browsers have slightly different rendering and they want a consistent look for their website across all platforms?func examineUAStringAndReturnJavascript() string { log.Print("WHY THE FUCK ARE YOU BROWSER SNIFFING?") os.Exit(1) return "false" }
That's why you use a responsive framework (e.g. knockoutJS) that handles all the browser compatibility crap for you.
-
Decisions, decisions....
-
-
-
-
-
@mikeTheLiar said:
One of these things is not like the other...
Yes. First one on the left is not a dog.