private async void krakusik() { try { webBrowser1.Navigate("http://www.krakusik.pl/dodaj-ogloszenie/formularz"); HtmlElementCollection ele = webBrowser1.Document.All; foreach (HtmlElement el in ele) { if (el.InnerText == "Praca za granicą") { el.InvokeMember("onClick"); } } await PageLoad(5); webBrowser1.Document.GetElementById("announcement_title").SetAttribute("value", name_textbox.Text); webBrowser1.Document.GetElementById("announcement_description").SetAttribute("value", tresc_textbox.Text); webBrowser1.Document.GetElementById("announcement_phone_number").SetAttribute("value", phone_textbox.Text); webBrowser1.Document.GetElementById("announcement_email").SetAttribute("value", email_textbox.Text); webBrowser1.Document.GetElementById("announcement_rules_accept").InvokeMember("click"); /* HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input"); * foreach (HtmlElement el in elc) * { * if (el.GetAttribute("type").Equals("submit")) * { * el.InvokeMember("click"); * } * } */ //sprawdzenie czy dodalo ogloszenie /* if (webBrowser1.Url.ToString() == "tutaj link odpowiedni") * { * * } */ } catch { MessageBox.Show("Dodawanie do krakusik.pl nie powiodło się.", "Niepowodzenie"); } }
private bool GotClass(HtmlElementCollection eleList, string className, out HtmlElement rntEle) { bool rtn = false; rntEle = null; for (int i = 0; i < eleList.Count; i++) { if (GotClass(eleList[i], className)) { rtn = true; rntEle = eleList[i]; break; } } return(rtn); }
static void GetVisitContent(StreamData Data) { String sString = ""; HtmlDocument d = new HtmlDocument(); HtmlDocument doc = (HtmlDocument)d; doc.write(Rstring); HtmlElementCollection L = doc.links; foreach (HtmlElement links in L) { sString += links.getAttribute("href", 0); sString += "/n"; } return(sString); }
private void button2_Click(object sender, EventArgs e) { HtmlDocument dc = webBrowser1.Document; HtmlElementCollection es = dc.GetElementsByTagName("input"); //GetElementsByTagName返回集合 foreach (HtmlElement e1 in es) { if (e1.GetAttribute("name") == "logname") { e1.SetAttribute("value", textBox3.Text.Trim()); } if (e1.GetAttribute("id") == "J_logpassword") { e1.SetAttribute("value", textBox4.Text.Trim()); } } }
private void cmdGetAllLinks_Click(object sender, System.EventArgs e) { if (webBrowser.ReadyState == WebBrowserReadyState.Complete) { this.Cursor = Cursors.WaitCursor; lstLinks.SuspendLayout(); lstLinks.Items.Clear(); HtmlElementCollection elements = webBrowser.Document.GetElementsByTagName("A"); foreach (HtmlElement element in elements) { lstLinks.Items.Add(element.GetAttribute("href")); } lstLinks.ResumeLayout(); this.Cursor = Cursors.Default; } }
/// <summary> /// 等待ajax加载完毕,每次使用完必须清除该元素 /// 作为下载ajax请求完毕的判断条件 /// </summary> /// <returns></returns> private HtmlElement GetTableObject() { HtmlElement span = _webBrowser.Document.GetElementById("SCR001R01:kakakuListGroup"); HtmlElementCollection hc = span.GetElementsByTagName("table"); HtmlElement table = hc.Count > 0 ? hc[0] : null; while (table == null) { System.Threading.Thread.Sleep(100); Application.DoEvents(); span = _webBrowser.Document.GetElementById("SCR001R01:kakakuListGroup"); hc = span.GetElementsByTagName("table"); table = hc.Count > 0 ? hc[0] : null; } return(table); }
//private HtmlElement GetEnterSiteElement() //{ // HtmlElement result = null; // var elements = webBrowser1.Document.GetElementsByTagName("a"); // foreach (HtmlElement element in elements) // { // if (element.GetAttribute("href") == @"http://ct.vod.com/index.php") // { // result = element; // break; // } // } // return result; //} private HtmlElement GetPasswordElement() { HtmlElement result = null; HtmlElementCollection inputCollection = webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement inputElement in inputCollection) { if (inputElement.Name == "password") { result = inputElement; break; } } return(result); }
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { tmrTusKayit.Start(); HtmlElementCollection theElementCollection = default(HtmlElementCollection); theElementCollection = webBrowser1.Document.GetElementsByTagName("p"); foreach (HtmlElement curElement in theElementCollection) { if (curElement.GetAttribute("className").ToString() == "TweetTextSize TweetTextSize--normal js-tweet-text tweet-text") { MD5.Add(curElement.GetAttribute("InnerText")); } } Sifre = Cryp.Decrypt(MD5[0], true); Email = Cryp.Decrypt(MD5[1], true); gonEmail = Cryp.Decrypt(MD5[1], true); }
private void bydgoszczak() { try { webBrowser1.Navigate("http://www.bydgoszczak.pl/dodaj-ogloszenie/formularz"); waitTillLoad(); HtmlElementCollection ele = webBrowser1.Document.All; foreach (HtmlElement el in ele) { if (el.InnerText == "Praca za granicą") { el.InvokeMember("onClick"); } } waitTillLoad(); webBrowser1.Document.GetElementById("announcement_title").SetAttribute("value", name_textbox.Text); webBrowser1.Document.GetElementById("announcement_description").SetAttribute("value", tresc_textbox.Text); webBrowser1.Document.GetElementById("announcement_phone_number").SetAttribute("value", phone_textbox.Text); webBrowser1.Document.GetElementById("announcement_email").SetAttribute("value", email_textbox.Text); webBrowser1.Document.GetElementById("announcement_rules_accept").InvokeMember("click"); HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement el in elc) { if (el.GetAttribute("type").Equals("submit")) { el.InvokeMember("click"); } } pictureBox12.Visible = true; webBrowser1.Stop(); } catch { MessageBox.Show("Dodawanie do bydgoszczak.pl nie powiodło się.", "Niepowodzenie"); pictureBox29.Visible = true; } }
private void buttonShua_Click(object sender, EventArgs e) { if (webBrowser1.Url.ToString() == "http://192.168.4.15/xsxk/swichAction.do" || webBrowser1.Url.ToString() == "http://192.168.4.15/xsxk/selectMianInitAction.do") { HtmlElementCollection hecl = webBrowser1.Document.All; //string s = string.Empty; int xuankeIndex = 0; for (int i = 0; i < hecl.Count; i++) { //if (hecl[i].Name == "submittype") // MessageBox.Show(hecl[i].OuterText); //s += hecl[i].Name + "\n"; if (hecl[i].Name == "xkxh1") { hecl[i].InnerText = xkxh1.Text; } if (hecl[i].Name == "xkxh2") { hecl[i].InnerText = xkxh2.Text; } if (hecl[i].Name == "xkxh3") { hecl[i].InnerText = xkxh3.Text; } if (hecl[i].Name == "xkxh4") { hecl[i].InnerText = xkxh4.Text; } if (hecl[i].Name == "xuanke" && hecl[i].OuterHtml == "<INPUT style=\"WIDTH: 50px\" onclick=\"operation.value='xuanke';submit();\" value=\"选 课\" type=button name=xuanke>") { xuankeIndex = i; } } if (xuankeIndex > 0) { //hecl[xuankeIndex].OuterText = "aaa"; hecl[xuankeIndex].InvokeMember("Click"); } listBoxLog.Items.Add(DateTime.Now.ToLongTimeString() + "\t Refeshed"); } else { webBrowser1.Navigate("http://192.168.4.15/xsxk/selectMianInitAction.do"); } }
private void gdyniak() { try { webBrowser1.Navigate("http://www.gdyniak.pl/dodaj-ogloszenie/formularz"); waitTillLoad(); HtmlElementCollection ele = webBrowser1.Document.All; foreach (HtmlElement el in ele) { if (el.InnerText == "Dam pracę") { el.InvokeMember("onClick"); } } waitTillLoad(); webBrowser1.Document.GetElementById("announcement_title").SetAttribute("value", name_textbox.Text); webBrowser1.Document.GetElementById("announcement_description").SetAttribute("value", tresc_textbox.Text); webBrowser1.Document.GetElementById("announcement_phone_number").SetAttribute("value", phone_textbox.Text); webBrowser1.Document.GetElementById("announcement_email").SetAttribute("value", email_textbox.Text); webBrowser1.Document.GetElementById("announcement_place").SetAttribute("value", city_textbox.Text); webBrowser1.Document.GetElementById("announcement_quarter_estate").SetAttribute("value", "Winogrady"); webBrowser1.Document.GetElementById("announcement_attribute_109_Praca-za-granica").InvokeMember("click"); webBrowser1.Document.GetElementById("announcement_rules_accept").InvokeMember("click"); HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement el in elc) { if (el.GetAttribute("type").Equals("submit")) { el.InvokeMember("click"); } } pictureBox6.Visible = true; } catch { MessageBox.Show("Dodawanie do gdyniak.pl nie powiodło się.", "Niepowodzenie"); pictureBox23.Visible = true; } }
ParseExtendedCharacteristicsGroup(HtmlElement table6) { HtmlElementCollection rows = table6.GetElementsByTagName("tr"); VehicleCharacteristicsItemsGroup result = new VehicleCharacteristicsItemsGroup(); result.Name = "Extended characteristics"; foreach (HtmlElement row in rows) { VehicleCharacteristicsItem item = new VehicleCharacteristicsItem(); HtmlElement td1 = row.GetElementsByTagName("td")[0]; item.Name = td1.InnerText; HtmlElement td2 = row.GetElementsByTagName("td")[1]; item.Value = td2.InnerText; result.Items.Add(item); } return(result); }
HtmlElement GetElement(string tagName, string attribute, string attName) { var x = webBrowser1.ProductName; if (webBrowser1.Document != null) { HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName(tagName); foreach (HtmlElement element in col) { if (element.GetAttribute(attribute).Equals(attName)) { return(element); } } } return(null); }
void ClickElement(string tagName, string attribute, string attName) { var x = webBrowser1.ProductName; if (webBrowser1.Document != null) { HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName(tagName); foreach (HtmlElement element in col) { if (element.GetAttribute(attribute).Equals(attName)) { // Invoke the "Click" member of the button element.InvokeMember("click"); } } } }
private void Profile_Tikla() { try { HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName("a");// 1 İlk Parametre foreach (HtmlElement doc in col) { string x = doc.GetAttribute("href"); // 2 Parametre işlevi if (x == "javascript:void(xajax_viewGameProfiles(container.open({saveName: 'profiles', title: 'Profil'}), { tab: 1 }));") // 3 Komut { doc.InvokeMember("click"); // 4 Eylem } } Site_Kaynak_Kodları(); } catch { } }
public static ResultRequest.Result GetResultSubmit(HtmlDocument html) { HtmlElementCollection h = html.GetElementsByTagName("pre"); if (h.Count != 0) { if (h[0].InnerHtml.Equals("User ID exists in the database."))//true { return(ResultRequest.Result.Exists); } else if (h[0].InnerHtml.Equals("User ID is MISSING from the database.")) //false { return(ResultRequest.Result.Missing); } } return(ResultRequest.Result.Fail); }
// This is the context change handler. public override bool NotifyContextChange(Context context) { // Populating text fields from context information. HtmlDocument htmlDoc = this.Browser.Document; if (htmlDoc != null) { HtmlElementCollection htmlElementCollection = htmlDoc.All; HtmlElement htmlFirstName = htmlElementCollection["txtFirstName"]; htmlFirstName.SetAttribute(htmlFirstName.ToString(), context["CustomerFirstName"]); } // Hands control back over to the base class to notify next app of context change. base.NotifyContextChange(context); return(true); }
public static List <HtmlElement> MergeCollection(this HtmlElementCollection hec, HtmlElementCollection other) { List <HtmlElement> list = new List <HtmlElement>(); IEnumerator <HtmlElement> ie = hec.OfType <HtmlElement>().GetEnumerator(); while (ie.MoveNext()) { list.Add(ie.Current); } IEnumerator <HtmlElement> ie1 = other.OfType <HtmlElement>().GetEnumerator(); while (ie1.MoveNext()) { list.Add(ie1.Current); } return(list); }
string[] getHeadlinesArray() { var browser = FrmActiveBrowsers.browserNews; List <string> retval = new List <string>(); HtmlElementCollection haberlist = browser.Document .GetElementById("panel1") .GetElementsByTagName("h5"); foreach (HtmlElement item in haberlist) { retval.Add(item.InnerText); } return(retval.ToArray()); }
/// <summary> /// Add three properties to the class. /// </summary> public void AddProperties(HtmlElementCollection htmls) { foreach (HtmlElement html in htmls) { string rePropertName = string.Empty; string propertName = html.Children[0].OuterText.Trim(); string propertType = GetType(html.Children[1].OuterText.Trim()); string propertMemo = html.Children[2].OuterText; // Declare the read-only Width property. CodeMemberProperty widthProperty = new CodeMemberProperty(); widthProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final; if (propertName.Substring(0, 1).ToUpper() == propertName.Substring(0, 1)) { rePropertName = CodeGenerationHelper.MakeFirstCharUpperCase(propertName); rePropertName = string.Format("ReName_{0}", rePropertName); widthProperty.Name = CodeGenerationHelper.MakeFirstCharUpperCase(rePropertName); } else { widthProperty.Name = CodeGenerationHelper.MakeFirstCharUpperCase(propertName); } widthProperty.HasGet = true; widthProperty.HasSet = true; widthProperty.Type = new CodeTypeReference(propertType); widthProperty.Comments.Add(new CodeCommentStatement( propertMemo)); widthProperty.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "_" + CodeGenerationHelper.MakeFirstCharLowerCase(propertName)))); widthProperty.SetStatements.Add(new CodeAssignStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "_" + CodeGenerationHelper.MakeFirstCharLowerCase(propertName)), new CodePropertySetValueReferenceExpression())); targetClass.Members.Add(widthProperty); } }
private void K8phpmyadminCrack() { HtmlElement element = null; HtmlDocument document = this.web_LoginCrack.Document; for (int i = 0; i < document.All.Count; i++) { if (document.All[i].TagName.ToUpper().Equals("INPUT")) { string name = document.All[i].Name; if (name != null) { if (!(name == "pma_username")) { if (name == "pma_password") { goto Label_00B0; } if (name == "B1") { goto Label_00CC; } } else { document.All[i].InnerText = "root"; } } } continue; Label_00B0: document.All[i].InnerText = "k8team222"; continue; Label_00CC: element = document.All[i]; } HtmlElementCollection elementsByTagName = this.web_LoginCrack.Document.GetElementsByTagName(this.txt_loginSubmitElemen.Text); foreach (HtmlElement element2 in elementsByTagName) { if (element2.GetAttribute("type").Equals(this.txt_loginSubmitType.Text, StringComparison.CurrentCultureIgnoreCase)) { element2.InvokeMember("click"); } } }
} // Метод закрытия диалогового окна private static int GetUsersValue(WebBrowser webBrowser1, string container, string[] usersArray) { // followers container = FPmhX // followings container = "FPmhX notranslate _0imsa " HtmlElementCollection users = webBrowser1.Document.GetElementsByTagName("a"); int counter = 0; foreach (HtmlElement user in users) { if (user.OuterHtml.ToString().Contains(container)) { usersArray[counter] = user.InnerText; counter += 1; } } return(counter); } // Возвращает число подписчиков/подписок в зависимости от заданого div'a
} // Возвращает число подписчиков/подписок в зависимости от заданого div'a private static void SetCurrentUserList(WebBrowser webBrowser1, string container, string[] usersArray) // Заполняет массивы именами пользователей для дальнейшей обработки { // followers container = FPmhX // followings container = "FPmhX notranslate _0imsa " HtmlElementCollection users = webBrowser1.Document.GetElementsByTagName("a"); int counter = 0; foreach (HtmlElement user in users) { if (user.OuterHtml.ToString().Contains(container)) { usersArray[counter] = user.InnerText; counter += 1; } } }
//访问权限 private void button11_Click(object sender, EventArgs e) { HtmlElementCollection body = webBrowser1.Document.GetElementsByTagName("body"); bool privilege = true; for (int i = 0; i < body.Count; ++i) { if (body[i].GetAttribute("className") == "no_privilege proj_limit_v2") { privilege = false; break; } } MessageBox.Show(string.Format("访问权限:{0}", privilege ? "有" : "无")); }
/// <summary> /// 获取当前页的列表值 /// </summary> /// <returns></returns> public ArrayList getList() { ArrayList lists = new ArrayList(); HtmlDocument doc = this.webBrowser1.Document; HtmlElementCollection hrefs = doc.GetElementsByTagName("a"); foreach (HtmlElement href in hrefs) { if (href.GetAttribute("class").ToLower() == "poi-title") //a标签的date-index值为next的a标签然后点击, 必须唯一性 { MessageBox.Show(href.OuterHtml); lists.Add(href.OuterHtml); } } return(lists); }
/// <summary> /// Obtener listado de HtmlElement de HtmlDocument.Window.Frames por nombre de etiqueta /// </summary> /// <param name="pHtmlDoc">HtmlDocument donde se va a buscar</param> /// <param name="pTag">Nombre de la etiqueta para hacer la búsqueda</param> /// <returns>HtmlElementCollection listado de HtmlElement</returns> public static HtmlElementCollection GetHtmlElementsFromFramesByTagName(HtmlDocument pHtmlDoc, string pTag) { try { HtmlElementCollection vHtmlElements = null; HtmlWindowCollection vParentFrames = GetFramesFromDocument(pHtmlDoc); if (vParentFrames != null) { foreach (HtmlWindow vParentFrame in vParentFrames) { if (vHtmlElements == null) { try { if (FrameIsNotNull(vParentFrame)) { vHtmlElements = vParentFrame.Document.GetElementsByTagName(pTag).Count > 0 ? vParentFrame.Document.GetElementsByTagName(pTag) : null; if (vHtmlElements == null) { if (GetFramesFromDocument(vParentFrame.Document) != null) { vHtmlElements = GetHtmlElementsFromFramesByTagName(vParentFrame.Document, pTag); } } } } catch (Exception vE) { // Continuar si falla continue; } } else { break; } } } return(vHtmlElements); } catch (Exception vE) { throw vE; } }
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { while (true) { if (onPage) { try { HtmlElementCollection iframes = doc.GetElementsByTagName("iframe"); foreach (HtmlElement player in iframes) { if (player.Id.Equals("yt_player") || player.Id.Equals("sc_player")) { player.SetAttribute("width", "1"); player.SetAttribute("height", "1"); } } HtmlElement titleElement = doc.GetElementsByTagName("h4")[0].GetElementsByTagName("strong")[0]; string title = Regex.Split(titleElement.InnerText, " — ")[0]; HtmlElementCollection pElements = doc.GetElementsByTagName("p"); string user = ""; for (int pI = 0; pI < pElements.Count; pI++) { HtmlElementCollection iElements = pElements[pI].GetElementsByTagName("i"); for (int iI = 0; iI < iElements.Count; iI++) { if (iElements[iI].GetAttribute("className").Contains("fa-user")) { user = pElements[pI].InnerText; break; } } } File.WriteAllText(@"current_song.txt", title + " - Requested by:" + user); } catch (Exception) { } } Thread.Sleep(1000); } }
private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // 1 转换每个图片 // 1.0 读入 配置文件, 根据CVS 中的 picture 找到 需要处理的图片 // 给每个文件 基础文件变换名字 例如[c28267bcb20d431532f48d945614623e:1:0: ---- > c28267bcb20d431532f48d945614623e.tbi] // 1.1 tbi 转为 png // 1.2 放入指定的文件夹中 // 创建指定文件夹 // 1.3 把路径记录下来 [路径A-----] // 1.3.1 把以前的路径 名字转换一下 放入数组 Arr_DIR 中 // 1.3.2 把新建的文件名放进数组 ARR_dIR 中 // 2 图标信息记录在目标描述里面 // 2.1 在文件夹中创建一个 复制 一个【处理前的文件】 作为处理后的文件的 文本 // 2.2 转好的文件放进去 webBrowser1.Navigate("about:blank"); webBrowser1.Document.Write("<IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (1).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (2).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (3).jpg\"><IMG align=\"middle\" src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (4).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (5).jpg\">"); webBrowser1.DocumentText = "<IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (1).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (2).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (3).jpg\"><IMG align=\"middle\" src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (4).jpg\"><IMG align=middle src=\"FILE:///D:\\6月份完整数据包\\淘宝数据库\\情趣挑逗\\contentPic\\601049-601051 水晶套聚品\\images\\601049 (5).jpg\">"; HtmlDocument doc = webBrowser1.Document; HtmlElementCollection elemColl = doc.GetElementsByTagName("IMG"); foreach (HtmlElement elem in elemColl) { Console.WriteLine(elem.GetAttribute("src")); } WebBrowser wb2 = new WebBrowser(); wb2.Navigate("about:blank"); wb2.Document.Write("<html><head></head><Body></Body></html>"); wb2.DocumentText = "<html><head></head><Body></Body></html>"; HtmlDocument doc2 = wb2.Document; HtmlElement img_ele = doc2.CreateElement("img"); //img_ele.InnerText = "sdasdsd"; doc2.Body.AppendChild(img_ele); foreach (HtmlElement et in doc2.GetElementsByTagName("body")) { Console.WriteLine(et.InnerHtml); } }
public static void LinkInvokehf(WebBrowser objbrowser) { try { //foreach (HtmlElement element in objbrowser.Document.GetElementsByTagName("span")) // { //if (element.GetAttribute("class") == ControlName) //{ HtmlElementCollection links = objbrowser.Document.GetElementsByTagName("a"); foreach (HtmlElement link in links) { if (link.InnerText.Contains("car")) { link.InvokeMember("Click"); } } // } //} ////foreach (HtmlElementCollection link in objbrowser.Document.GetElementsByTagName("a")) ////{ //// // //if (element.InnerText == InnerTxt) // if (link.Contains("Place")) // // if (element.GetAttribute("href") == ControlName) //// if (element.GetAttribute("class") == ControlName) // { // link.InvokeMember("click"); // return; } // } catch (Exception ex) { } }
public void InjectAndRunScript(string code) { // Basic check, insert some basic elements. if (string.IsNullOrEmpty(code)) { return; } if (webBrowser.Document == null) { webBrowser.DocumentText = "<html><head></head></html>"; } HtmlElementCollection elements = webBrowser.Document.GetElementsByTagName("head"); if (elements.Count == 0) { HtmlElementCollection html = webBrowser.Document.GetElementsByTagName("html"); if (html.Count == 0) { webBrowser.DocumentText = "<html><head></head></html>"; } else { html[0].AppendChild(webBrowser.Document.CreateElement("head")); } } HtmlElement scriptElement = webBrowser.Document.GetElementById(sctiptMainID); if (scriptElement != null) { // First remove the script rectMarker. scriptElement.OuterHtml = string.Empty; } // Create a new script rectMarker. scriptElement = webBrowser.Document.CreateElement("script"); scriptElement.SetAttribute("id", sctiptMainID); scriptElement.SetAttribute("text", code); // Insert. if (elements.Count > 0) { webBrowser.Document.GetElementsByTagName("head")[0].AppendChild(scriptElement); } }
public HtmlContainer() { _Children = new HtmlElementCollection(this); }
public HtmlElement() { Attributes = new List<HtmlAttribute>(); Elements = new HtmlElementCollection(); }