Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change title name in HTML forcefully

I have a project it consist of 30+ ‘JS’ files and a index file. I have changed the title name of page in the index file but it only shown to me when I reload the page. After the reload complete it show me old title name

Now I am accepting is there any forceful script which always change the title and used as priority in changing the title name or any way by i can find that which particular ‘JS’ file has been used in changing the title

Explained above

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can always use this line document.title = "Some title";, the problem is, you have to know where to put this, cuz it’s probable that currently in your project, the title is set by js dynamically and there might be some triggers for that (e.g. on a lifecycle DOMContentLoaded). To tackle that, it’s also possible to freeze the title so that it can’t be changed anymore after this code is executed, but you can try this:

Object.defineProperty(document, 'title', {
  enumerable: false,
  configurable: false,
  writable: false,
  value: "Some title"
});

though the latter might have some side effects that I have no idea, but hopefully it could satisfy the requirement.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading