Blog

A Series of Pungent Posts and Personality

Read through our most recent posts below. If you are going to comment, please add real value to the discussion.

How Do I assign the BODY tag a class in Volusion?

We will tell you right now! Here it is! Before you simply copy/paste the code into your site, let me preface this freebie with some explanation and a few guidelines:

  1. You can expand this out to any of the Volusion pages/experiences you need.
  2. There are always other (better?) ways to write Javascript. You could even do this with jQuery. Don’t marry yourself to it. This was an off-the-cuff script but it works!
  3. You can remove the comments if you need to. Totally up to you.
  4. Place this in between the HEAD tags of the Volusion template file you are using.

<script type="text/javascript"> 
// Schawel Volusion Thingies
// Tested on Volusion Winter09 and V11
$(function() {
  var loc = window.location.href; // COMMENT A
  if(/default/.test(loc)) {
    $('body').addClass('ishomepage'); // COMMENT B
}
  if(/about/.test(loc)) {
    $('body').addClass('about');  // COMMENT C
}
  if(/specialarticle_a/.test(loc)) {
    $('body').addClass('special'); // COMMENT D
}
});
</script>

  • This will grab the full URL of your site
  • If the URL in the browser is that famous “default.asp” page then this adds the “ishomepage” class to that body tag
  • This looks for any URL string that has the word “about” in it. Generally this is the aboutus.asp but could also be anything like /aboutus-a/123.htm
  • This is advanced document writing. We search for any URL string that has “specialarticle_a” in it, that is an SEO friendly article and then add the “special” class to the body tag.

Now you have can do some really cool things like collapsing TABLES which we know everyone wants to do, hiding various BR tags, or even assigning special .css to various product page HTML. Every Volusion designer knows what we are talking about.