Dynamically Change Page Title Using Javascript

I was over on Google Finance looking up a stock ticker during trading hours and I noticed the equity price was being updated not only on the page, but also on the HTML page Title. How did they do it? With a single line of Javascript.

document.title = "This is the new page title.";

What if the page is inside a frameset? In that case just add parent to the front.

parent.document.title = "This is the new page title.";

This sample code by itself is rather dull, but with a timer it could be used to create a cool effect like an updating stock ticker.

This entry was posted in Javascript and tagged . Bookmark the permalink.

Comments are closed.