Your question is a bit unclear because it starts talking about links and such. But you do specifically mention document.title
, so...
If you set document.title
, there's no way to set it back to its previous value without your saving the previous value and then restoring it, e.g.:
// Setting the value originally, remember the previous value first:
document.previousTitle = document.title;
document.title = "Testing 1 2 3";
// Restoring the previous title:
document.title = document.previousTitle;
document.previousTitle = undefined;
(Ideally, instead of clearing the previousTitle
with document.previousTitle = undefined;
, we'd use delete document.previousTitle;
, but sadly that breaks on IE because document
isn't really a JavaScript object, it just behaves very much like one, mostly.)
You might think: Let's go find the title
element in the head
and use its original content to restore the title. (That's what I thought.) But no, setting document.title
actually updates the content of the title
element in the head
, so that doesn't work. You have to save the original somewhere else.