Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Script Fails to Change the Document Title of a Web Page


Symptoms

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


Resolution

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


Status

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


More information

Steps to Reproduce Behavior

  1. 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>
    					
  2. 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.
  3. 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


References

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


Properties

Retired KB Content Disclaimer
This 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


Keywords: KB296113, kbnofix, kbdhtml, kbbug

↑ Back to the top

Article Info
Article ID : 296113
Revision : 4
Created on : 10/24/2012
Published on : 10/24/2012
Exists online : False
Views : 152