Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created October 25, 2009 15:10
Show Gist options
  • Save eligrey/218119 to your computer and use it in GitHub Desktop.
Save eligrey/218119 to your computer and use it in GitHub Desktop.
"use strict";
// lockTitle() returns a function that is allowed to change the title after it is locked
// This only works in browsers that support the DOMTitleChanged event (only Firefox)
var lockTitle = function () {
lockTitle = undefined;
var titleChanging = false,
title = document.title;
document.addEventListener("DOMTitleChanged", function () {
if (titleChanging) {
title = document.title;
titleChanging = false;
return;
}
document.title = title;
}, false);
var changeTitle = function (title) {
titleChanging = true;
document.title = title;
};
return changeTitle;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment