Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

I HATE this so much

Back to Forum: Tech Off
  • User profile image
    Andrew Davey

    Add a WebBrowser activeX control to a form (VS2003).
    Make it Navigate to a page that has frames.

    add a code that does this:

    IHTMLDocument2 doc = (IHTMLDocument2)axWebBrowser1.Document;

    object oI;
    int len = (int)doc.frames.length;
    for (int i = 0; i < len; i++) {
     oI = i;
     mshtml.IHTMLWindow2 frame = (mshtml.IHTMLWindow2)
    ref oI);

    So it should display the name of each frame in the document - but NO! It throws some stupid System.UnauthorizedAccessException. WTF?!

    Any ideas?

    Is it some kind of SP2 problem?

  • User profile image
    Sven Groot

    Seems to work okay here... I tried it on, it gave me the frame names without problems. And I am using SP2.

    Could you post a complete, compilable example that demonstrates this problem, as well as the website you are encountering this problem with?

  • User profile image

    I don't know if this will help but I have had problems before when accessing frames that, to the browser, appear to come from different domains.

    For example, your server machine might be called "andrew" so your frame is loaded from "http://andrew/", however, the other frames were referred to using a fully qualified domain name like "". If you try to access the other frames they appear (to the browser) to belong to another site, and thus, it will not let you access them.

    In my case, the solution was as simple as using a fully qualified domain when refereing to the page in the browser.  i.e. Try using "" in the browser URL bar instead of "http://andrew/".

    I  hope this helps.

  • User profile image

    Hey Guys,
    Sorry if I am answering an already answered question (?) but I thought I would pipe up on this one as I just discovered the delights of such a snippet of code last week.

    The problem which I came across, which is called cross site scripting. Search on Microsoft Knowledge Base is actually a security precaution in IE and Outlook and can be quite a pain in the you will no doubt already have realised.

    The way we got round it here was quite fortunate. The app in question is actually part of an HTML Application (HTA) and by setting the application=yes trusted=yes attributes the code within any of it's pages is allowed to do anything they gawd darn like.

    Hope this was of assistance,

  • User profile image
    Andrew Davey

    Full story is I'm making a IE toolbar plug-in that scans the current page (and recurses thru frames) to find all <a> tags and then determines if the linked doc is an RSS 2.0 feed. The page contains a single frame pointing to a radio userland blog. This is obviously on a different domain so I guess the security is disallowing my access. Sad Is there no way to tell the runtime to really trust my code? Failing that I'll have to manually parse the HTML for frames then HTTP GET each frame page Tongue Out yuck.

    Anyway, thanks for the feedback guys - very much appreciated.

  • User profile image

    Andrew, I feel your pain.  I've been suffering with this problem for the last full week.  I've tried all kinds of stuff to attempt to get past this access error.

    This thing that doesn't make sense about the explanation by MrJelly is that all of my frames are coming from the same server.  It's an intranet page that provides web-based access to our mainframe.  All I want to do is have it hit a couple of buttons and parse through the contents of one of the panes to identify high-severity trouble tickets.  Since all panes are hosted on the same server, I'm really lost about the IHTMLWindow2 object throwing the message "UnauthorizedAccessException: Access is denied".

    I attempted to use the SHDocVw.InternetExplorerClass object directly, thinking that ther error was being generated by the mshtml library, but got the same error.

    Please let me know if I have any other options.  Unfortunately, I can't manually parse these frames since I need to have the code virtually hit Java-based buttons, rather than performing a regular submit.


  • User profile image

    I think I know the solution. You need to add the fully qualified host name of the web site you are connecting to the trusted list of web sites in your IE and set the security level for trusted sites to low.

    Tools > Internet Options > Security > Trusted Sites
  • User profile image

    I had been looking for this solution for a while. So easy and yet so frustating.


Conversation locked

This conversation has been locked by the site admins. No new comments can be made.