BUG: Internet Explorer May Stop Responding When You Load Nested Element Behaviors (319738)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5.5
  • Microsoft Internet Explorer (Programming) 5.5 SP2
  • Microsoft Internet Explorer (Programming) 6.0

This article was previously published under Q319738

SYMPTOMS

When you load a page that uses nested element behaviors and then insert a custom element in response to an event, Internet Explorer may stop responding, or hang. The hang may occur if the nested elements also load external script or Extensible Markup Language (XML) data.

RESOLUTION

To work around this problem:
  • For XML data, insert the XML data island in response to an event.
  • For script code, send an Expires header with the script file.
  • For either XML data or script code, place the XML data or the script in-line.

STATUS

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

MORE INFORMATION

Steps to Reproduce the Behavior

There are two ways to cause Internet Explorer to hang:
  • If the cause of the problem is a SCRIPT tag with a src attribute, then you can avoid the problem if you add Hypertext Transfer Protocol (HTTP) headers that make sure that the browser does not request the script file for some predetermined period of time. For example, in Internet Information Server (IIS) you can set the content expiration so that the script file expires at a time in the future, such as in a day. See the "References" section for additional information.
  • Another way to cause Internet Explorer to hang is to send the script file with Expires and Cache-control: max-age HTTP headers.
In this example, the max-age value of 86400 seconds means the file may be kept in a cache for about a day.
Expires: (date)
Cache-control: max-age=86400
				
If the cause of the problem is an XML tag with a src attribute, you can avoid the problem if you modify the HTML Control (HTC) so that the XML data island is inserted dynamically as shown in the following code sample:
testDiv.insertAdjacentHTML("afterEnd", "<xml src=\"Inner.xml\"/>");
				

The following code sample illustrates both causes. You create five files in the following sample. If you use this sample, you must apply both workarounds together.
  1. Create the Sample.htm file:
    <HTML xmlns:ctrl>
    <HEAD>
        <?import namespace="ctrl" implementation="outer.htc">
        <TITLE>Sample Q319738</TITLE>
    </HEAD>
    <BODY>
        <ctrl:outer></ctrl:outer>
    </BODY>
    </HTML>
    
    					
  2. Create the Outer.htc file:
    <html xmlns:ctrl>
    	<?import namespace="ctrl" implementation="inner.htc" />
    <head>
    <public:component tagName="outer">
    	<public:defaults viewLinkContent="true" />
    	<public:attach event=oncontentready onevent="DoElementInsert()" />
    </public:component>
    <script language="JavaScript">
    function DoElementInsert()
    {
    	idDiv.innerHTML = "<ctrl:inner/>";
    }
    </script>
    </head>
    <body style="border: darkgray 2px solid; background-color:lightgrey; padding=5px;">
    	This is the outer element behavior. <br>
    	<div id="idDiv" style="BACKGROUND-COLOR: white">
    		Text in this DIV gets replaced.
    	</div>
    </body>
    </html>
    
    					
  3. Create the Inner.htc file:
    <html>
    	<head>
    		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    		<public:component tagName="inner">
    			<public:defaults viewLinkContent="true" />
    		</public:component>
    		<!-- this script tag will cause a hang if the browser is requesting pages on every visit to the page. -->
    		<script language="javascript" src="inner.js" ></script>
    	</head>
    	<body>
    		<div style="border: 1px solid darkgrey; background-color: lavender; padding: 5px;"
    			id="testDiv">
    			This is the inner element behavior.
    		</div>
    		<!-- This XML tag will cause a hang unless it is inserted dynamically -->
    		<xml src="inner.xml"/>
    	</body>
    </html>
    
    					
  4. Create the Inner.js file:
    	function doNothing() {
    		// Do nothing.
    	}
    
    					
  5. Create the Inner.xml file:
    <?xml version="1.0" encoding="utf-8" ?> 
    <anytag>
    	Any XML will do.
    </anytag>
    					
  6. Save all of these files on an HTTP server.
  7. Start Internet Explorer and explore to the Sample.htm page. For example, explore to http://localhost/Q319738/Sample.htm.
After you complete the preceding steps, you can see the behavior.

If you follow the preceding steps, but you cannot reproduce the behavior, check the following :
  1. Verify that the page is accessed through HTTP protocol (http://). If you access the file from file protocol (file://) you may not be able to reproduce the behavior.
  2. Verify that the caching setting for Internet Explorer is set to Every visit to the page.
    1. To confirm this setting, on the Tools menu, click Internet Options.
    2. From the General tab, click Settings in the Temporary Internet Files panel.
    3. In the Settings dialog box, click to select Every visit to the page in the Check for newer versions of stored pages check box.
  3. Verify that all five files that you created are located in the same virtual directory.

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

313561 HOW TO: Set HTTP Headers for Content Expiration in Internet Information Services (IIS) 5.0

For information about the HTTP Protocol standard and the meaning and the proper values of HTTP headers, visit the following Web site:

Hypertext Transfer Protocol -- HTTP/1.1
http://www.w3.org/Protocols/rfc2616/rfc2616.html


Modification Type:MajorLast Reviewed:5/10/2003
Keywords:kbBug kbpending KB319738