468,532 Members | 1,721 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

IHTMLPopup Error - Cross Frame Security

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?

Jul 8 '06 #1
2 4318
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"rb******@metacrawler.com" wrote:
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?

Jul 8 '06 #2
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:
//IHTMLWindow4 parentWindow = (IHTMLWindow4)FrameDocument.parentWindow;
IHTMLWindow4 parentWindow = (IHTMLWindow4)PageDocument.parentWindow;
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.

Peter wrote:
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"rb******@metacrawler.com" wrote:
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?
Jul 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Charles Crume | last post: by
5 posts views Thread by Jim Marquardson | last post: by
7 posts views Thread by Scott M. | last post: by
3 posts views Thread by Vongza | last post: by
9 posts views Thread by permanent.tourist | last post: by
4 posts views Thread by taoberly | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.