private void InnerInstallScript(HtmlDocument document) { WebBrowser2.InstallJQuery(document.DomDocument as IHTMLDocument); string code = this.GetJSCode(); WebBrowser2.AttachScript(document.DomDocument as IHTMLDocument, code); }
private void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) { WebBrowser2 browser = sender as WebBrowser2; browser.ObjectForScripting = new WebPageCloseHandler(browser.Parent as TabPageWithWebBrowser); HtmlDocument doc = FindDocument(browser.Document, e.Url); if (doc != null) { WebBrowser2.AttachScript(doc.DomDocument as IHTMLDocument, AttachScript, HtmlElementInsertionOrientation.AfterBegin); if (opener != null) { browser.Document.Cookie = opener.document.cookie; browser.Document.InvokeScript("setOpener", new object[] { opener }); } } this.Text = string.IsNullOrEmpty(browser.Document.Title) ? "未命名" : browser.Document.Title; }