Using HTML Layout Content in Internet Explorer 3.02 and 4.0

ID: Q183977


The information in this article applies to:


SUMMARY

This sample demonstrates a method of presenting HTML Layout content in both Microsoft Internet Explorer 3.02 and Microsoft Internet Explorer 4.0.


MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

~ Alxport.exe (34K)

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

Q119591 How to Obtain Microsoft Support Files from Online Services
Microsoft Internet Explorer 4.0 Dynamic HTML (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).

Microsoft Internet Explorer 4.0 and later warn users about the HTML Layout control, depending on security settings. For additional information, please see the following article in the Microsoft Knowledge Base:
Q183803 INFO: The HTML Layout Control Treated as Unsafe Control in IE4
With minor modifications, your existing HTML Layout files can be used in both Internet Explorer 3.02, 4.0, and later.

The content of an HTML Layout file is encapsulated by <DIV> tags. Here's an example:

<DIV ID="SampleLayout"
STYLE="LAYOUT:FIXED;WIDTH:419pt;HEIGHT:149pt;">
... content here ...
</DIV> 

The following modifications must be made to the layout file if it is to be used in both Internet Explorer 3.02 and 4.0:
  1. Add an absolute position style attribute to each <OBJECT> tag contained within the <DIV> tags. Here's an example:
    
    <OBJECT ...
    STYLE="position:absolute;...">
    ... params here ...
    </OBJECT> 


  2. If you need to dynamically modify the z-index of elements, remove the z- index style attribute from each <OBJECT> tag. The sample file, Redblue.htm provides an example of z-index behavior.


  3. Add script to detect the browser version. Perform the following actions depending on which version is being used.


  4. Add script to dynamically generate the correct HTML. Because the modified layout file contains valid DHTML, you can use an <IFRAME> tag to display the content in Internet Explorer 4 and later. Use an <OBJECT> tag to insert the HTML Layout control for Internet Explorer 3.02. See the sample file Alxport.htm for details.

    Internet Explorer 3.02

    
    document.write('<OBJECT');
    document.write(' CLASSID="CLSID:812AE312-8B8E-11CF-93C8-0AA00C08FDF"');
    document.write(' CODEBASE=');
    document.write(
    '"http://activex.microsoft.com/controls/mspert10.cab#version=1,0,5,1"');
    document.write(' ID="Html_Layout1" STYLE="LEFT:0;TOP:0">');
    document.write(' <PARAM NAME="ALXPATH" REF VALUE="RedBlue2.htm">');
    document.write('</OBJECT>'); 

    Internet Explorer 4.0

    
    document.write('<IFRAME MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=0');
    document.write(' WIDTH=564 HEIGHT=254 SRC="RedBlue2.htm">');    


  5. Because CSS style attributes are available only with Internet Explorer 4.0 DHTML, use the object property if the browser is Internet Explorer 3.02. For example, to hide an HTML element:

    Internet Explorer 3.02

    
    Label2.Visible = false; 

    Internet Explorer 4.0

    Label2.style.display = "none";


  6. Add an onload event handler to the HTML layout file to perform any initialization. For Internet Explorer 3.02, an onload event is fired for the layout <DIV> tag and, with later scripting engine versions, for the window object. For Internet Explorer 4.0, an onload event is fired for the window object. See the sample file Alxfile.htm for more details.

    Internet Explorer 3.02

    
    <SCRIPT LANGUAGE="VBScript" FOR="Layout1" EVENT="OnLoad">
       // handle HTML Layout control OnLoad event; occurs for IE3.02
       StartupCode()
    </SCRIPT> 

    Internet Explorer 4.0

    
    <SCRIPT LANGUAGE="VBScript" FOR="Window" EVENT="OnLoad">
       // handle window OnLoad event; occurs for IE4 and for IE3.02
       // with later scripting engine versions
       StartupCode()
    </SCRIPT> 


  7. When using Internet Explorer 4.0, the onclick event is not fired for the Microsoft Forms 2.0 Image Control. Add an onclick event handler to a surrounding <DIV> tag to determine which image object was clicked. The sample file Redblue.htm demonstrates this. Any event handler in the <DIV> tag will be ignored by the HTML Layout control. This can be used to implement browser specific behavior.


  8. Rename the HTML layout file from an .alx extension to an .htm extension to avoid users being prompted to open or save the file when included as the source of an <IFRAME> tag in Internet Explorer 4.0.



REFERENCES

For more information, see the MSDN Online Web Workshop:

http://msdn.microsoft.com/workshop/
For additional information, please see the following article in the Microsoft Knowledge Base:
Q183803 INFO: The HTML Layout Control Treated as Unsafe Control in IE4

Additional query words: ALX LAYOUT


Keywords          : kbcode kbfile kbActiveDocs kbActiveX kbIE400 kbIE401 kbIE302 kbACS kbIE500 
Version           : WINDOWS:1.0,3.02,4.0,4.01,5.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: May 13, 1999