30 Ocak 2013 Çarşamba

How to dynamically change a web page's title?


You can change the title via three ways:


1- (does not work in IE) put <title id='ttl'>Hello</title> in html, thendocument.getElementById('ttl').innerHTML = 'World' in javascript.
2- (similar to 1) put <title>Hello</title> in html, and thendocument.getElementsByTagName('title')[0].innerHTML = 'world'
3- (works everywhere) document.title = 'World'
1 and 2 are slightly obscure and unstandard ways to change the title, and is probably not reccomended, so I would go with the third, seeing as it works in every browser