CodeSOD: Height of the Accordion

This post was originally published on this site

The Daily WTF

In the bad old days of web development, you had to deal with the fact that there weren’t really any standards, and you had to customize your code for different browsers. The “right” way was to sniff for which features were available, but the most commonly used way was to check the user-agent string and guess based on the browser name. Because of this, browsers started to keyword spam their user-agent, to pass these checks, which is why my browser reports as Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36. My browser of choice is a Chrome fork, and I’m running on an M1 Mac, so basically none of those things are true.

But let’s look back at some code Lucas found, still lingering in a web app he maintains.

if (navigator.appName == ‘Microsoft Internet Explorer’) { $(“##accordion”).accordion({ autoHeight: false }); } else { $(“##accordion”).accordion({

To read the full article click on the 'post' link at the top.