Home > Software engineering >  How to change title name in HTML forcefully
How to change title name in HTML forcefully

Time:01-03

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

CodePudding user response:

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.

  • Related