Microsoft KB Archive/183977

= SAMPLE: Using HTML Layout Content in Internet Explorer Versions 3.02 and 4.0 or Later =

Article ID: 183977

Article Last Modified on 8/9/2004

-

APPLIES TO


 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet ActiveX Controls 1.0

-



This article was previously published under Q183977



SUMMARY
The sample in this article demonstrates how to present HTML Layout content in Internet Explorer 3.02, with equivalent approaches in Internet Explorer 4.0 or later.

Because there is an architecture change in Internet Explorer 4.0, Microsoft recommends that you use Dynamic HTML (DHTML) rather than the HTML Layout control to dynamically position HTML elements when you script for Internet Explorer 4.0 and later. The HTML Layout ActiveX control is developed with the single-threaded architecture, and Internet Explorer 4.0 or later uses apartment-threaded architecture. This discrepancy may lead to a compatibility problem and may cause unexpected behavior. For more information on developing an ActiveX control with Internet Explorer, see the following Microsoft Web site:

Building ActiveX Controls for Internet Explorer 4.0

http://msdn.microsoft.com/workshop/components/activex/buildax.asp



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Alxport.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. In Internet Explorer 4.0 or later, DHTML provides a way to dynamically position HTML elements. Before dynamic positioning was available as Cascading Style Sheets (CSS) style attributes, the HTML Layout ActiveX control was developed to allow Web authors to position elements by means of an HTML Layout file (.alx).

Internet Explorer 4.0 or later warns users about the HTML Layout control, depending on security settings. For additional information, please see the following article in the Microsoft Knowledge Base: For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

183803 INFO: HTML Layout Control Is Treated as an Unsafe Control in Internet Explorer 4.x and 5.x

With minor modifications, your existing HTML Layout files can be used in both Internet Explorer versions 3.02 and 4.0 or later.

The content of an HTML Layout file is encapsulated by  tags. For example:  ... content here ...  You must make the following modifications to the layout file if you want to use it in Internet Explorer versions 3.02 and 4.0 or later:   Add an absolute position style attribute to each  tag that is contained within the  tags. For example:  ... parameters here ...   If you need to dynamically modify the z-index of elements, remove the z-index style attribute from each  tag. The sample file, Redblue.htm, provides an example of z-index behavior. Add script to detect the browser version.</li>  Add the following script to dynamically generate the correct HTML.

Note Because the modified layout file contains valid DHTML, you can use an <IFRAME> tag to display the content in Internet Explorer 4.0 or later. Use an  tag to insert the HTML Layout control for Internet Explorer 3.02. See the sample file Alxport.htm for detailed information.

In Internet Explorer 3.02, add the following script: document.write(''); document.write(' <PARAM NAME="ALXPATH" REF VALUE="RedBlue2.htm">'); document.write('</OBJECT>'); In Internet Explorer 4.0 or later, add the following script: document.write('<IFRAME MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=0'); document.write(' WIDTH=564 HEIGHT=254 SRC="RedBlue2.htm">'); </li>  Because CSS style attributes are available only with Internet Explorer 4.0 DHTML, use the object property if your browser is Internet Explorer 3.02.

For example, to hide an HTML element in Internet Explorer 3.02: Label2.Visible = false; In Internet Explorer 4.0 or later: Label2.style.display = "none"; </li>  Add an onload event handler to the HTML layout file to perform any initialization.

Note In Internet Explorer 3.02, an onload event is fired for the layout  tag and, with later scripting engine versions, for the window object. In Internet Explorer 4.0 or later, an onload event is fired for the window object. See the sample file Alxfile.htm for more detailed information.

In Internet Explorer 3.02: <SCRIPT LANGUAGE="VBScript" FOR="Layout1" EVENT="OnLoad"> // Handle HTML Layout control OnLoad event; this occurs for Internet Explorer 3.02 StartupCode </SCRIPT> In Internet Explorer 4.0 or later: <SCRIPT LANGUAGE="VBScript" FOR="Window" EVENT="OnLoad"> // Handle window OnLoad event; occurs for Internet Explorer versions 4.0 // or later and 3.02 with later scripting engine versions. StartupCode </SCRIPT> </li> In Internet Explorer 4.0 or later, the onclick event is not fired for the Microsoft Forms 2.0 Image Control. Add an onclick event handler to a surrounding  tag to determine which image object was clicked. The sample file, Redblue.htm, demonstrates this. The HTML Layout control ignores any event handler in the  tag. This can be used to implement browser specific behavior.</li> Rename the HTML layout file from an .alx extension to an .htm extension so that users are not prompted to open or save the file when it is included as the source of an <IFRAME> tag in Internet Explorer 4.0 or later.</li></ol>

<div class="references_section">