Microsoft KB Archive/296113

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

Article ID: 296113

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q296113



SYMPTOMS
Internet Explorer fails to change the document title when client-side script sets the innerHTML property of a title object that CreateElement(&quot;Title&quot;) creates.



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 &quot;More Information&quot; section.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
  Create a new HTML page called Test.htm, and paste the following code:   

function runTest {   var s =&quot;We should set this as the new title&quot; var mytitle = document.createElement(&quot;TITLE&quot;); mytitle.innerHTML = s;   alert(s); document.documentElement.childNodes[0].appendChild(mytitle);

} function fix {   var s = &quot;Now we change the title&quot;; alert(s); document.title = s; }       </HTML> </li> <li>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.</li> <li>Click Workaround. Script that uses document.title sets the title of the document. Notice that the title of the Internet Explorer window changes.</li></ol>

<div class="references_section">