Feb
3
Written by:
Dylan Barber
2/3/2010 10:42 AM
With jQuery and CSS becoming so much more the norm for web development it becomes even more necessary to be able to manipulate classes on elements not in the skin, specifically the body tag.
There are really two ways to do this and each has it benefits and problems, jQuery and inline code.
Jquery: This method is so simple simply add in the skin and it will add whatever class to the body tag, in DNN the id of the body tag is ‘Body’. The only problem with this method is if you are depending on that class being there even if jQuery fails to run you are out of luck.
Inline Code: the method uses a simple bit of inline vb.net code to add the class to the body tag
Now this method will work as long as DNN works it only depends on the ASP.NET parser parsing the file out as it will have to for any DNN portal to work. The problem here is there is that millisecond of more processing.
Both methods are valid and work fine – I think the second method is a bit more reliable since a user could have JavaScript turned off on the client then your site may look strange if you have coded CSS classes for the body.
Tags: