IHTMLPopup Error - Cross Frame Security

  • Thread starter Thread starter rbanerji
  • Start date Start date
R

rbanerji

I am building a BHO that is meant to popup a IHtmlPopup window on a
mouse over image event. All the code works fine if the image is in the
main Window.

However if the image is in a frame then I get the following error:

{"Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED))"} System.Exception
{System.UnauthorizedAccessException}

This happens when I try to create the Popup Window or access its
Document
The code below is in C#, but I think it would apply to C++ too.

I have tried getting the parentWindow from the Frame's document and
from the main document.


//IHTMLWindow4 parentWindow = (IHTMLWindow4)FrameDocument.parentWindow;
IHTMLWindow4 parentWindow = (IHTMLWindow4)PageDocument.parentWindow;

//This line will work, but if you look at the Document Property, you
will see the exception
IHTMLPopup popUp = (IHTMLPopup)parentWindow.createPopup( ref argIn );
//This line will throw the exception
IHTMLDocument2 popupDoc = (IHTMLDocument2)popUp.document;


Any ideas?
 
The only way to prevent this that I know of is to change the setting in
Advanced section of client browser (IE) settings. You cannot acess the
contents of a frame (IFRAME) whose source is another domain, for security
reasons.
Peter
 
Thanks Peter,

I guess I should clarify my question a little. I know that I am
experienceing Cross Frame security issues. What I am trying to achieve
is to popup some sort of a tooltip equivalent on a mouseover event.

I think my code is causing the cross frame security issue because I am
not using the correct windows to create the popup. In my code I said I
tried the two methods:

OageDocument is the main Document and I can see why this would go wrong
when using Frames.

FrameDocument is the document of the Frame of the element over which
the mouse is hovering. I therefore figured that
FrameDocument.parentWindow will return me the right window to create a
popup. Obviuosly that does not seem to be the case.

Any idea, then, as to which Window I should be using? I know the
element I am hovering over, the document of the frame and the main
document.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top