Using IFRAME Elements

Note  As of December 2011, this topic has been archived and is no longer actively maintained. For more information, see Archived Content. For information, recommendations, and guidance regarding the current version of Windows Internet Explorer, see Internet Explorer Developer Center.

In Microsoft Internet Explorer 5.5 and later, frames are windowless, resulting in greatly improved performance. In addition, Internet Explorer 5.5 and later can now overlap IFRAME elements—also known as inline floating frames—and can make the content inside inline floating frames transparent.

Inline floating frames provide the following features:

  • Increased performance over previous versions of Internet Explorer. Internet Explorer 5.5 and later have been optimized to handle inline floating frames more efficiently. This means faster rendering, less memory, and faster scrolling.
  • Inline floating frames can be stacked over other inline floating frames.
  • Inline floating frames can contain transparent content.

The following topics are discussed in this document:

Creating Inline Floating Frames

To create a inline floating frame, use the IFRAME tag.

<iframe name="Frame1" src="frame.htm" >

The IFRAME tag creates a floating frame at its location in the HTML file. Internet Explorer renders the frame inline. The SRC attribute specifies the content to be displayed within the frame.

You can also place content into the previous IFRAME tag by using a frame destination, as follows:

<a href="" target="Frame1">See Microsoft's Web Site</a>

The previous example creates a hyperlink that navigates to Microsoft's Web site inside the inline floating frame. It uses the TARGET attribute to load the Web page into the IFRAME. The NAME attribute on the IFRAME tag indicates the TARGET for the A tag.

Security Warning:   To protect user privacy and safeguard your applications, Internet Explorer restricts some interactions between frames that host Web pages from different domains. For more information about using the Dynamic HTML (DHTML) object model with the frame and iframe objects, see About Cross-Frame Scripting and Security and Security Considerations: Dynamic HTML.

Using Transparency with Inline Floating Frames

Although Internet Explorer has supported transparent elements since Microsoft Internet Explorer 4.0, only Internet Explorer 5.5 and later support transparent content with inline floating frames.

The following conditions must be met to define transparent content for inline floating frames.

Note  The BGCOLOR attribute can be applied to the BODY element, but it is deprecated as of HTML 4.0. It is recommended that you use the background-color attribute instead.

The following example shows how to apply the background-color attribute to the IFRAME content source file.

    <body style="background-color:transparent">

The following example shows how the IFRAME element is written for transparent content.

<iframe name="Frame1" src="frame.htm" allowTransparency="true">

Stacking Inline Floating Frames

Internet Explorer 4.0 and later supports the z-index attribute. However, only Internet Explorer 5.5 and later support the z-index attribute with inline floating frames. By specifying the z-order of floating frames, you can stack one frame on top of another.

To specify the position of the inline floating frame, use the z-index attribute.

<iframe src="frame.htm" style="z-index:1" >

Items are stacked from a smaller z-index value to a larger z-index value, and the value can be negative.

Related topics

Security Considerations: Dynamic HTML