2010.08.28

The perils of HTML body id attributes


BarbedOne crucial part of building any web application is the administration area, or 'admin panel'. Often these are very utilitarian so are styled entirely differently to the customer-facing site.

I, and I'm sure a lot of others, achieve this is by giving the body tag in the HTML and unique ID to denote whether the page is part of the admin-panel or the main site. Some of my coding standards can be pretty ephemeral so the exact ID I use from one project to another tends to change. This is probably a good thing for all sorts of reasons but recently it caused me hours of frustration and unnecessary coding.

To a lot of people the problem, never mind the solution, has already occurred to them. Basically I fired up Firefox and saw a blank screen. Why I didn't bother to try it in another browser immediately baffles me to this day, but I didn't. Cue hours of making all sorts of changes to the markup, turning off all JavaScript, disconnecting the database etc. etc.

Eventually of course I opened it in Chrome and it all worked fine. Back in Firefox and desperate for answers I looked up. Not up so high as to leave the edge of the monitor (as what good would that do?) but up to the toolbar. There was the big, red, menacing face of Adblock Plus. I turned it off, hit F5 and up it came, turned it off and my admin-panel vanished.

Cue yet more code-wrangling, remming out, extensive use of console.log(). After a good hour, lots of Pepsi Max and mere seconds away from hitting the power button to head to the pub, the cause and solution leapt out at me from the glow of Notepad++:

<body id='adbody'>

programming

Burst forth on 28th August 2010 at 11:08 and vaguely filed under programming.

Witty rejoinders


Nothing yet!

(never published)
http://
Captcha: