Skip to content

Instantly share code, notes, and snippets.

@0x4a
Created March 13, 2014 03:58
Show Gist options
  • Save 0x4a/9521688 to your computer and use it in GitHub Desktop.
Save 0x4a/9521688 to your computer and use it in GitHub Desktop.
check if page title ends in string, append string when not - #jQuery #work
jQuery(document).ready(function($){
var title_shop = " | Samenhaus Müller";
var title_page = encodeURI($(document).attr('title'));
var regex = new RegExp(encodeURI(title_shop) + "$");
if (title_page.match(regex) == null)
{
$(document).attr('title', decodeURI(title_page) + title_shop);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment