Eric Yin
Eric Yin

Reputation: 8983

The document.title is NOT Document <title>

ok, this is weird, and I like to have an idea if this is possible

e.g.

the page

<title>12345</title>

then if js is if(document.title=='12345')...

I guess this must be true, BUT my counter tells me otherwise, 10% is NOT (most in IE)

So I like to know, is there any browser plugin or other stuff does this and make document.title is NOT <title>

Upvotes: 1

Views: 96

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

Try logging what document.title is if it isn't '12345'.

The most likely thing is if the file is being transferred with chunked encoding (a common feature in HTTP/1.1) then the <title> tag may be split in half and this would cause an incorrect title to show up.

This can be fixed by adding:

window.onload = function() {document.title = document.getElementsByTagName('title')[0].firstChild.nodeValue;};

Upvotes: 1

Related Questions