Internet Explorer fails to change the document title when client-side script sets the innerHTML property of a title object that CreateElement("Title") creates.
↑ Back to the top
To work around this problem, use the document.title property to set the title programmatically instead. For sample code that demonstrates this workaround, see the "More Information" section.
↑ Back to the top
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
↑ Back to the top
Steps to Reproduce Behavior
- Create a new HTML page called Test.htm, and paste the following code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT">
function runTest()
{
var s ="We should set this as the new title"
var mytitle = document.createElement("TITLE");
mytitle.innerHTML = s;
alert(s);
document.documentElement.childNodes[0].appendChild(mytitle);
}
function fix()
{
var s = "Now we change the title";
alert(s);
document.title = s;
}
</SCRIPT>
</HEAD>
<BODY>
<input type="button" value="Problem" onclick="runTest()"/>
<input type="button" value="Workaround" onclick="fix()"/>
</BODY>
</HTML>
- Click Problem. Script is called to set the innerHTML property of a title object. Notice that the title of the Internet Explorer window does not change.
- Click Workaround. Script that uses document.title sets the title of the document. Notice that the title of the Internet Explorer window changes.
↑ Back to the top
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
263033 BUG: DHTML Dialog Box Does Not Show String Assigned to Document.Title
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
↑ Back to the top
Retired KB Content DisclaimerThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
↑ Back to the top