-2

I'm trying to add the notification number to the title in a function, but it won't work. This is my code:

  var docTitle = document.title;

  document.title = "".docTitle." (".$(".loadnot").html().")";
imp
  • 460
  • 2
  • 7
  • 23

4 Answers4

9

In JavaScript you should use + for concatenating not ..

document.title = docTitle + "(" + $(".loadnot").html() + ")";
Ram
  • 143,282
  • 16
  • 168
  • 197
4

Or even better:

document.title += " ("+$(".loadnot").html()+")";
JCOC611
  • 19,111
  • 14
  • 69
  • 90
0

check this:

window.top.document.title = "Your Title";
johnpatoki
  • 21
  • 5
0

If none of the answers above fit then is simply:

Some Javascript server side is blocking the changing of the document title.

Check how -> https://stackoverflow.com/a/27847787/16759195

All you have to do is to add to your code the following lines:

Object.defineProperty(document, 'title', {
  enumerable: true,
  configurable: true,
  writable: true,
  value: document.title
});
Crypto-Frank
  • 142
  • 6