Article ID: 937266 - Last Review: October 31, 2007 - Revision: 1.1

A relative URL is not related to an IFrame when you dynamically create a style element that uses a relative URL for an external .css file in an HTML document

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
Expand all | Collapse all

SYMPTOMS

In an HTML document, you dynamically create a style element. The style element uses a relative URL for an external cascading style sheet (.css) file. If the HTML document that contains the style element is embedded in an inline frame (IFrame), the relative URL is not related to the IFrame as expected. The URL is incorrectly related to the parent frame.

For example, you create an HTML document that is named Parent.html in a folder. This folder also contains a folder that is named Inner. The Inner folder contains an HTML document that is named Child.html and a GIF image that is named Test.gif. You embed the Child.html file into an IFrame in the Parent.html file. In the Child.html file, you dynamically create a style element to reference the URL of the Test.gif file. However, you cannot use "./Test.gif" to reference the URL of the Test.gif file. You must use "../Inner/Test.gif" to reference the URL of the Test.gif file.

Note If you hardcode the URL in the HTML document and do not use a .css file, this problem does not occur.

WORKAROUND

To work around this problem, use one of the following methods:
  • Use the absolute path to reference the URL.
  • Put the following documents in the same folder:
    • The HTML document of the IFrame
    • The HTML document of the parent document

MORE INFORMATION

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
937265  (http://support.microsoft.com/kb/937265/ ) The URL of an ActiveX control is not related to the IFrame when you use the CODEBASE attribute to set the URL of an ActiveX control in an HTML document

APPLIES TO
  • Microsoft Internet Explorer (Programming)
Keywords: 
kbtshoot kbprb KB937266
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.