Created
October 25, 2009 15:10
-
-
Save eligrey/218119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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