webbrowser-control

Webbrowser control: Get element value and store it into a variable

送分小仙女□ 提交于 2019-12-17 16:41:48
问题 Winform: Web browser Control The web browser has the following displayed content, within a html table. [Element] [Value] Name John Smith Email jsmith@hotmail.com For the example above, the html code, might look something like this <table> <tbody> <tr> <td><label class="label">Name</label></td> <td class="normaltext">John Smith</td> </tr> <tr> <td><label class="label">Email</label></td> <td><span class="normaltext">jsmith@hotmail.com</span></td> </tr> </tr> </tbody> </table> . I want to get

Using WebBrowser in a console application

此生再无相见时 提交于 2019-12-17 16:09:33
问题 I want to use it to invoke some JS scripts on the webpage. I have this: static void Stuff() { WebBrowser browser = new WebBrowser(); browser.Navigate("http://www.iana.org/domains/example/"); HtmlDocument doc = browser.Document; //doc.InvokeScript("someScript"); Console.WriteLine(doc.ToString()); } static void Main(string[] args) { Console.WriteLine("hi"); var t = new Thread(Stuff); t.SetApartmentState(ApartmentState.STA); t.Start(); } Question 1: I get an "object reference not set" exception

How to set and delete cookies from WebBrowser Control for arbitrary domains

落爺英雄遲暮 提交于 2019-12-17 16:08:55
问题 How can I set and delete cookies for a domain in webbrowser control without using Javascript ( which doesn't allow to set / delete cookies without navigating to the website first. ) 回答1: Managed to accomplish this task by combining these 2: http://support.microsoft.com/kb/815718 and INTERNET_OPTION_END_BROWSER_SESSION - http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328(v=vs.85).aspx 回答2: Hope this helps using System.Runtime.InteropServices; namespace Storm8 { class Program {

Set WPF webbrowser control to use IE10 mode

北战南征 提交于 2019-12-17 09:51:33
问题 How can i set the WPF webbrowser controls to render pages in iE10 mode or the higher version installed on machine . By default if i create a .net 4 or .net 4.5 application on any machine of OS > windows 7 , it renders the html pages in IE7 mode only. (Please correct if i am wrong) How to enable the application to render the html pages in IE10 mode if IE10 installed on target machine ? Any helps 回答1: You can use the registry as described here: http://msdn.microsoft.com/en-us/library/ie

How to inject CSS in WebBrowser control?

别等时光非礼了梦想. 提交于 2019-12-17 09:30:23
问题 As per my knowledge,there is a way to inject javascript into the DOM. Below is the sample code that injects javascript with the webbrowser control: HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; element.text = "function sayHello() { alert('hello') }"; head.AppendChild(scriptEl); webBrowser1.Document.InvokeScript("sayHello"); Is

Displaying html from string in WPF WebBrowser control

本秂侑毒 提交于 2019-12-17 08:29:05
问题 My data context object contains a string property that returns html that I need to display in WebBrowser control; I can't find any properties of WebBrowser to bind it to. Any ideas? Thanks! 回答1: The WebBrowser has a NavigateToString method that you can use to navigate to HTML content. If you want to be able to bind to it, you can create an attached property that can just call the method when the value changes: public static class BrowserBehavior { public static readonly DependencyProperty

Get ReadyState from WebBrowser control without DoEvents

随声附和 提交于 2019-12-17 07:41:07
问题 This has been awnsered many times here and at other sites and its working, but I would like ideas to other ways to: get the ReadyState = Complete after using a navigate or post, without using DoEvents because of all of its cons. I would also note that using the DocumentComplete event woud not help here as I wont be navigating on only one page, but one after another like this. wb.navigate("www.microsoft.com") //dont use DoEvents loop here wb.Document.Body.SetAttribute(textbox1, "login") //dont

Perform screen-scape of Webbrowser control in thread

早过忘川 提交于 2019-12-17 06:49:33
问题 I am using the technique shown in WebBrowser Control in a new thread Trying to get a screen-scrape of a webpage I have been able to get the following code to successfully work when the WebBrowser control is placed on a WinForm . However it fails by providing an arbitrary image of the desktop when run inside a thread. Thread browserThread = new Thread(() => { WebBrowser br = new WebBrowser(); br.DocumentCompleted += webBrowser1_DocumentCompleted; br.ProgressChanged += webBrowser1

Open link in new TAB (WebBrowser Control)

ⅰ亾dé卋堺 提交于 2019-12-17 06:11:11
问题 Does anybody know how to click on a link in the WebBrowser control in a WinForms application and then have that link open in a new tab inside my TabControl? I've been searching for months, seen many tutorials/articles/code samples but it seems as though nobody has ever tried this in C# before. Any advice/samples are greatly appreciated. Thank you. 回答1: Based on your comments, I understand that you want to trap the "Open In New Window" action for the WebBrowser control, and override the

How to invoke scripts work in msHTML

ぐ巨炮叔叔 提交于 2019-12-17 05:14:26
问题 I'm using axWebBrowser and I need to make a script work which works when selected item of a listbox is changed. In default webBrowser control there is a method like; WebBrowserEx1.Document.InvokeScript("script") But in axWebBrowser I can not work any script! And there is no documentation about this control. Anyone knows how ? 回答1: A late answer, but hopefully still may help someone. There is a number of ways to invoke a script when using WebBrowser ActiveX control. The same techniques can