private bool IsFrameInDocument(HTMLDocument doc, string contexturl) { for (int i = 0; i < doc.frames.length; i++) { object itemRef = i; mshtml.HTMLWindow2 frmElem = (HTMLWindow2)doc.frames.item(ref itemRef); HTMLIFrame frm = (HTMLIFrame)frmElem.frameElement; if (frm.src != null) { string temp = frm.src; Debug.WriteLine("Found Frame: " + temp); if (contexturl.EndsWith(frm.src, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } if (frmElem.document != null) { HTMLDocument subdoc = (HTMLDocument)frmElem.document; if (IsFrameInDocument(subdoc, contexturl)) { return(true); } } } return(false); }
private void runjs() { var docx = webBrowser2.Document; var frame = docx.Window.Frames; IHTMLDocument3 doci = CorssDomainHelper.GetDocumentFromWindow(frame["course_frm"].DomWindow as IHTMLWindow2); HTMLIFrame if2 = doci.getElementById("course_frame") as HTMLIFrameClass; if2.contentWindow.execScript(tb4.Text); }