Microsoft KB Archive/325482

= PRB: Cannot Insert a Style Sheet Using a Res: Protocol URL =

Article ID: 325482

Article Last Modified on 5/10/2003

-

APPLIES TO


 * Microsoft Internet Explorer (Programming) 5.5 SP1
 * Microsoft Internet Explorer (Programming) 5.5 SP2

-



This article was previously published under Q325482



SYMPTOMS
An ActiveX control or other code that manipulates a DHTML document can change the appearance of the document by using the IHTMLDocument2::createStyleSheet method to add a style sheet to the document.

Before the installation of the May 15, 2002, Cumulative Patch for Internet Explorer, the style sheet can be drawn from a resource in the executable file. For example: hr = pDoc->createStyleSheet(&quot;res://c:\\mypath\\myctl.dll/101&quot;, -1, &pStyleSheet); After installing the May 15, 2002, Cumulative Patch for Internet Explorer, if the HTML document does not come from either the local computer or from a trusted site, you receive the following error message:

0x8007000E Out of memory

For more information about the May 15, 2002, cumulative patch, see the &quot;References&quot; section.



CAUSE
This behavior is by design.



RESOLUTION
To dynamically add a style sheet to a page, use one of the following options:   When you call IHTMLDocument2::createStyleSheet to create the style sheet, provide a URL that can be accessed, such as a relative URL. For example: hr = pDoc->createStyleSheet(&quot;/includes/mystyles.css&quot;, -1, &pStyleSheet); For more information, visit the following MSDN Web site:

IHTMLDocument2::createStyleSheet Method

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/ifaces/document2/createstylesheet.asp

 Create an empty style sheet by calling IHTMLDocument2::createStyleSheet with no URL. You can then add rules to this style sheet object by using its object model. For more information, visit the following MSDN Web site:

createStyleSheet Method

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/createstylesheet.asp

NOTE: The sites to which you are adding the style sheet have to be added to the Trusted sites zone.



MORE INFORMATION
To protect data on the local computer, after you install the cumulative patch mentioned in this article, Internet Explorer allows creation of a style sheet by using a file from the local computer only if the HTML page to which the style sheet is being added comes from either the local computer or from a Web site that is in the Trusted sites zone.

A resource from an executable file is considered to be from the local computer. This is true even if the executable is an ActiveX Control, an add-in to Internet Explorer, or a program that is hosting the WebBrowser Control.

