WebBrowser 跨域访问iframe页面的内容

作者: Robin 分类: Asp.net 发布时间: 2008-08-25 20:04
[ComImport(), ComVisible(true), Guid("6D5140C1-7436-11CE-8034-00AA006009FA"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IServiceProvider
{
   [return: MarshalAs(UnmanagedType.I4)][PreserveSig]
   int QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}

Guid IID_IWebBrowserApp = new Guid("{0002DF05-0000-0000-C000-000000000046}");
                        Guid IID_IWebBrowser2 = new Guid("{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}");
                        object spWebBrws = null;
                        spServiceProvider.QueryService
(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out spWebBrws);
                        SHDocVw.IWebBrowser2 adWeb = spWebBrws as SHDocVw.IWebBrowser2;
                        HTMLDocument adDoc = adWeb.Document as HTMLDocumentClass;
                        aColl = adDoc.getElementsByTagName("a");

                        foreach (HTMLAnchorElement a in aColl)
                        {
                            if (a.href != "" && (a.href.IndexOf("xunbin.com") > 0
|| a.href.IndexOf("www.xunbin.com/membersvc/") > 0))
                            {
                                if (!lbUrl.Items.Contains(a.href))
                                {
                                    lbUrl.Items.Add(a.href);
                                    //wbWeb.Navigate(href);
                                    a.click();
                                }
                            }
                        }
                        

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

标签云