Digital Colony!

Changing a 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.

Labels: ,

AddThis Social Bookmark Button

0 Comments:

 

Post a Comment

 

Digital Colony Copyright © 1999-2008 XHTML   508
This site uses Blogger, which is not 100% XHTML compliant.
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.