Alex Ritter
Alex Ritter

Reputation: 1041

Title tag loaded by JS document.title function not changing title tag in source view

I am currently running the following js on some of my pages to dynamically set the title tag on the page pulling from the h1 tag contained on that page.

document.title = document.getElementsByClassName("Category-H1")[0].innerHTML;

However, when I view the page's source, it still shows the old title tag, even after the js has changed it.

It was suggested to me that I might have to add an "onload event of the body", not sure if this would help, or what onload event I would need to run.

Any other ideas? Suggestions? Thanks - Alex

Upvotes: 0

Views: 393

Answers (1)

Kevin Boucher
Kevin Boucher

Reputation: 16675

The 'source' is just that ... it is the code returned from the server. In most cases to see DOM changes made after loading you will need to look at the code in Firebug or Chrome Inspector.

Upvotes: 1

Related Questions