This issue occurs if you dynamically add an attached behavior by replacing the inner HTML of an element, such as the
DIV element, by using the
createElement method or the
insertAdjacentHTML method, or by dynamically changing the
className property of an element.
Steps to reproduce the behavior
- Copy the following code sample, and then save the code sample to a file that is named Test.htm.
<HTML>
<HEAD>
<STYLE>
.UseBehavior
{
behavior: url(behavior.htc);
}
</STYLE>
<SCRIPT>
function DoClick()
{
SetTarget.innerHTML = "<DIV CLASS='UseBehavior'>Hello World</DIV>";
//Uncomment the following line to work around the problem.
//window.status="Finished";
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID="SetTarget">Click to try the test</DIV><BR>
<BUTTON onClick="DoClick()">Click to insert the attached behavior.</BUTTON>
</BODY>
</HTML>
- Copy the following code sample, and then save the code sample to a file that is named Behavior.htc. Put the Behavior.htc file in the same directory where the Test.htm file is located.
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="ondocumentready" ONEVENT="Element_DocumentReady()" />
<SCRIPT language="JScript">
function Element_DocumentReady()
{
// This is almost an empty behavior.
}
</SCRIPT>
</PUBLIC:COMPONENT>
- Open the Test.htm file, and then click Click to insert attached behavior.
After the text changes from "Click to try the test" to "Hello World", the behavior is added. The progress bar loads indefinitely.