Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to change the <title> tag based on the Salsa page type.
<script type="text/javascript">
// Script to change the <title> tag based on the type of Salsa page
// being displayed.
// @see https://salsasupport.zendesk.com/entries/67436410
$(function() {
m = window.location.href.match('(\\w+)_KEY');
var locator = null;
if (m != null && m.length > 0) {
switch(m[1]) {
case 'action':
locator = "#info-page h1:first-of";
break;
case 'donate_page':
// Note that you'll need to add "donation-title" to the title
// for a donation page. See the doc.
locator = '#salsa .donation-title';
break;
case 'event':
locator = ".event_view h1";
break;
case 'signup_page':
locator = 'form[name=data] h2:first-of';
break;
case 'unsubscribe_page':
locator = 'h3.title';
break;
default:
console.log ("---------------------------------------------------------------------");
console.log("\nThere's not a locator yet for a " + m[1] + " page.");
console.log("Please send this message to support@salsalabs.com at your convenience.");
console.log("\nThanks!\n");
console.log ("---------------------------------------------------------------------")
break;
}
if (locator != null) {
document.title = $(locator).html();
}
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.