johnbocook
1/31/2015 - 2:04 AM

Gets pathname (domain.com/pathname) and add's background image of same name.

Gets pathname (domain.com/pathname) and add's background image of same name.

//Get Pathname and Add background image of path for dynamic backgrounds.
var loc = window.location.pathname.substring(1);
if (loc === '') {
    $( "#marketing-header" ).css('background-image', 'url(/img/default-bg.jpg)');
} else {
    $( "#marketing-header" ).css('background-image', 'url(/img/'+loc+'.jpg)');
};