Return to Snippet

Revision: 15726
at July 22, 2009 15:49 by chrisjlee


Updated Code
/*
 * 		Body switcher class for Volusion
 * 		by Chris J. Lee
 * 		2009
*/

$(document).ready(function() {
	var loc = $()[0].location.href;
	var loc = $()[0].location.href;
	var c = loc.length-1; // String Count
	if (loc[c] == '/') { $('body').addClass('homepage'); }
	else {
		$('body').addClass('sub');
	}
	if (loc.match('default\.asp')) $('body').addClass('home');
	if (loc.match('-p/') || loc.match('ProductDetails\.asp')) $('body').addClass('product');
	if (loc.match('-s/')) $('body').addClass('category');
	if (loc.match('-a/') || loc.match('article\.asp\?')) $(body).addClass('article');
	if (loc.match('shoppingcart\.asp')|| loc.match('one-page-checkout\.asp')) $('body').addClass('shoppingcart');
	if (loc.match('returns\.asp')) $('body').addClass('article return');
	if (loc.match('aboutus\.asp')) $('body').addClass('article aboutus');
});

Revision: 15725
at July 14, 2009 17:43 by chrisjlee


Updated Code
/*
 * 		Body switcher class for Volusion
 * 		by Chris J. Lee
 * 		2009
*/

$(document).ready(function() {
	var loc = $()[0].location.href;
	var c = loc.length-1;
	(loc[c] == '/')? $(body).addClass('home'): 0;
	(loc.match('default\.asp'))? $(body).addClass('home'): 0;
	(loc.match('-p/'))? $(body).addClass('product'): 0;
	(loc.match('-s/'))? $(body).addClass('category'):0;
	if (loc.match('-a/') || loc.match('article\.asp\?')) $(body).addClass('article');
	(loc.match('shoppingcart\.asp'))? $(body).addClass('shoppingcart'):0;
});

Revision: 15724
at July 14, 2009 17:33 by chrisjlee


Initial Code
/*
 * 		Body switcher class for Volusion
 * 		by Chris J. Lee
 * 		2009
*/

$(document).ready(function() {
	var loc = $()[0].location.href;
	(loc.match('-p/'))? $(body).addClass('product'): 0;
	(loc.match('-s/'))? $(body).addClass('category'):0;
	if (loc.match('-a/') || loc.match('article\.asp\?')) $(body).addClass('article');
	(loc.match('shoppingcart\.asp'))? $(body).addClass('shoppingcart'):0;
});

Initial URL
hire.chrisjlee.net

Initial Description
Uses jquery and raw javascript to quickly add a class to the body class depending on what kind of page it is.

Initial Title
Volusion with Jquery Body Switcher Script

Initial Tags
jquery

Initial Language
jQuery