Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Wed, 2 Jul 2008 22:15:00 -0700,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


Problem in accessing the document object withing iframe   
Hi...

I want to access the images rendered within iframe. But whever i am trying 
to access it always gives me "Access Denied" and sometimes "Permission 
Denied" error.
I am accessing it using java script. Even I have tried to access using 
IHTMLElementCollection. But it gives the same error.

Please let me know how can i access the doucment object within iframe.

Thanks in advance.
Hetal
date: Wed, 2 Jul 2008 22:15:00 -0700   author:   Hetal

Re: Problem in accessing the document object withing iframe   
"Hetal"  wrote in message
news:323CADF9-D4BF-42EF-82F3-8C5DC1082A49@microsoft.com
> I want to access the images rendered within iframe. But whever i am
> trying to access it always gives me "Access Denied" and sometimes
> "Permission Denied" error.
> I am accessing it using java script. Even I have tried to access using
> IHTMLElementCollection. But it gives the same error.

You are blocked by cross-domain scripting security restrictions. This 
technique bypasses them:

http://support.microsoft.com/kb/196340

-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 3 Jul 2008 07:56:21 -0400   author:   Igor Tandetnik

Re: Problem in accessing the document object withing iframe   
Many Thanks for your reply. It gave me a new hope to access the frames.

I am working on C#.Net applcation and tried the way that has been suggested. 
and wrote the following code:

----------------------------------------------------------------------------------------------
Guid guidIOleContainer = typeof(IOleContainer).GUID;

// Here oDoc is the mshtml.HTMLDocument object
IntPtr punk = Marshal.GetIUnknownForObject(oDoc); 

object iOleContainer = new object();

// But this give me null
Type typeIOleContainer = this.GetType().GetInterface("IOleClientContainer");

IntPtr ppvContainerIntPtr = Marshal.GetIUnknownForObject(iOleContainer);

int hr = Marshal.QueryInterface(punk, ref guidIOleContainer, out 
ppvContainerIntPtr);

if (ppvContainerIntPtr != IntPtr.Zero)
{
     IOleContainer pOleContainer = 
(IOleContainer)Marshal.PtrToStructure(ppvContainerIntPtr, 	typeIOleContainer);

     Marshal.Release(punk);
                
      object[] objs = new object[20];

      pOleContainer.EnumObjects((int)tagOLECONTF.EMBEDDINGS, objs); //Access  

      IEnumUnknown pOleEnumObject = objs[0] as IEnumUnknown;

      MessageBox.Show(pOleEnumObject.ToString());
}
----------------------------------------------------------------------------------------------

But The problems are :
1) typeIOleContainer is always null.
2) Marshal.QueryInterface for IoleContainer always fails.

How can I access the IOleContainer interface using doucment object in .net.

Please let me know how can I proceed to access frames or Iframe elements. 

Thanks a lot,
Hetal

"Igor Tandetnik" wrote:

> "Hetal"  wrote in message
> news:323CADF9-D4BF-42EF-82F3-8C5DC1082A49@microsoft.com
> > I want to access the images rendered within iframe. But whever i am
> > trying to access it always gives me "Access Denied" and sometimes
> > "Permission Denied" error.
> > I am accessing it using java script. Even I have tried to access using
> > IHTMLElementCollection. But it gives the same error.
> 
> You are blocked by cross-domain scripting security restrictions. This 
> technique bypasses them:
> 
> http://support.microsoft.com/kb/196340
> 
> -- 
> With best wishes,
>     Igor Tandetnik
> 
> With sufficient thrust, pigs fly just fine. However, this is not 
> necessarily a good idea. It is hard to be sure where they are going to 
> land, and it could be dangerous sitting under them as they fly 
> overhead. -- RFC 1925 
> 
> 
>
date: Sat, 5 Jul 2008 02:16:00 -0700   author:   Hetal

Re: Problem in accessing the document object withing iframe   
"Hetal"  wrote in message
news:1A13178B-D53E-4A4D-9D0E-B19ED5172278@microsoft.com
> Many Thanks for your reply. It gave me a new hope to access the
> frames.
>
> I am working on C#.Net applcation

I know next to nothing about .NET. You may want to ask in 
microsoft.public.dotnet.framework.interop
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sat, 5 Jul 2008 11:45:32 -0400   author:   Igor Tandetnik

Re: Problem in accessing the document object withing iframe   
Starting from IE5 you should be able to cast the frame element to 
IWebBrowser2 and try to cast its document property to IHtmlDocument2, though 
the official way is to use IOleClientContainer.

You don't have a type library for IOleClientContainer and I guess you need 
to declare a managed version of this interface.


"Hetal"  wrote in message 
news:1A13178B-D53E-4A4D-9D0E-B19ED5172278@microsoft.com...
> Many Thanks for your reply. It gave me a new hope to access the frames.
>
> I am working on C#.Net applcation and tried the way that has been 
> suggested.
> and wrote the following code:
>
> ----------------------------------------------------------------------------------------------
> Guid guidIOleContainer = typeof(IOleContainer).GUID;
>
> // Here oDoc is the mshtml.HTMLDocument object
> IntPtr punk = Marshal.GetIUnknownForObject(oDoc);
>
> object iOleContainer = new object();
>
> // But this give me null
> Type typeIOleContainer = 
> this.GetType().GetInterface("IOleClientContainer");
>
> IntPtr ppvContainerIntPtr = Marshal.GetIUnknownForObject(iOleContainer);
>
> int hr = Marshal.QueryInterface(punk, ref guidIOleContainer, out
> ppvContainerIntPtr);
>
> if (ppvContainerIntPtr != IntPtr.Zero)
> {
>     IOleContainer pOleContainer =
> (IOleContainer)Marshal.PtrToStructure(ppvContainerIntPtr, 
> typeIOleContainer);
>
>     Marshal.Release(punk);
>
>      object[] objs = new object[20];
>
>      pOleContainer.EnumObjects((int)tagOLECONTF.EMBEDDINGS, objs); 
> //Access
>
>      IEnumUnknown pOleEnumObject = objs[0] as IEnumUnknown;
>
>      MessageBox.Show(pOleEnumObject.ToString());
> }
> ----------------------------------------------------------------------------------------------
>
> But The problems are :
> 1) typeIOleContainer is always null.
> 2) Marshal.QueryInterface for IoleContainer always fails.
>
> How can I access the IOleContainer interface using doucment object in 
> .net.
>
> Please let me know how can I proceed to access frames or Iframe elements.
>
> Thanks a lot,
> Hetal
>
> "Igor Tandetnik" wrote:
>
>> "Hetal"  wrote in message
>> news:323CADF9-D4BF-42EF-82F3-8C5DC1082A49@microsoft.com
>> > I want to access the images rendered within iframe. But whever i am
>> > trying to access it always gives me "Access Denied" and sometimes
>> > "Permission Denied" error.
>> > I am accessing it using java script. Even I have tried to access using
>> > IHTMLElementCollection. But it gives the same error.
>>
>> You are blocked by cross-domain scripting security restrictions. This
>> technique bypasses them:
>>
>> http://support.microsoft.com/kb/196340
>>
>> -- 
>> With best wishes,
>>     Igor Tandetnik
>>
>> With sufficient thrust, pigs fly just fine. However, this is not
>> necessarily a good idea. It is hard to be sure where they are going to
>> land, and it could be dangerous sitting under them as they fly
>> overhead. -- RFC 1925
>>
>>
>>
date: Mon, 7 Jul 2008 17:46:27 -0500   author:   Sheng Jiang[MVP] uss

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us