GetFrames() public méthode

Returns a list of IWebBrowser2 instances. Each IWebBrowser2 instance represents a FRAME
public GetFrames ( ) : List
Résultat List
        /// <summary>
        /// Attempts to return a List of IHTMLElements with the given Name or Id
        /// If document is frameset then all frames are searched
        /// </summary>
        /// <param name="NameOrId">Name or Id of the element</param>
        /// <returns></returns>
        public static List<IHTMLElement> GetElementsByNameOrId(cEXWB browser, string NameOrId)
        {
            List<IHTMLElement> elemCols = new List<IHTMLElement>();

            if ((browser == null) ||
                string.IsNullOrEmpty(NameOrId))
                return elemCols;

            IHTMLDocument2 doc2 = browser.WebbrowserObject.Document as IHTMLDocument2;
            if (doc2 == null)
                return elemCols;

            IHTMLElementCollection col = null;
            string elemname = string.Empty;
            if (browser.FramesCount() > 0)
            {
                List<IWebBrowser2> frames = browser.GetFrames();
                if (frames == null)
                    return elemCols;
                IHTMLDocument2 framedoc = null;

                foreach (IWebBrowser2 wb in frames)
                {
                    if (wb == null)
                        continue;
                    framedoc = wb.Document as IHTMLDocument2;
                    if (framedoc == null)
                        continue;
                    col = framedoc.all as IHTMLElementCollection;
                    if (col == null)
                        continue;
                    foreach (IHTMLElement elem in col)
                    {
                        if (elem != null)
                        {
                            elemname = elem.getAttribute("name", 0) as string;
                            if ((elem.id == NameOrId) ||
                                (elemname == NameOrId))
                            {
                                elemCols.Add(elem);
                            }
                        }
                    }
                }
            }
            else
            {
                col = doc2.all as IHTMLElementCollection;
                if (col == null)
                    return elemCols;
                foreach (IHTMLElement elem in col)
                {
                    if (elem != null)
                    {
                        elemname = elem.getAttribute("name", 0) as string;
                        if ((elem.id == NameOrId) ||
                            (elemname == NameOrId))
                        {
                            elemCols.Add(elem);
                        }
                    }
                }
            }

            return elemCols;
        }
        public static IHTMLDocument2 GetDocumentFromFrame(cEXWB browser, string frameName)
        {
            List<IWebBrowser2> frames = browser.GetFrames();
            foreach (IWebBrowser2 wb in frames)
            {
                IHTMLFrameBase elem = (IHTMLFrameBase)wb;
                if ((!string.IsNullOrEmpty(elem.name))
                    && (elem.name == frameName))
                {
                    IHTMLDocument2 doc = (IHTMLDocument2)wb.Document;
                    //string body = doc2.body.innerHTML;
                    return doc;
                }

            }
            return null;
        }