webbrowser-control

How to invoke custom Javascript in System.Windows.Forms.WebBrowser?

ⅰ亾dé卋堺 提交于 2019-12-06 06:53:04
问题 I'm loading third party webpage that contains following code <script type="text/javascript"> onDomReady(function() { some_code1; }); </script> into WebBrowser component. After some_code1 had executed I need to do some manipulations with Dom that will make some_code1 invalid. The question is how to determine that some_code1 had executed? I cant't do private void web_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { DoRequiredManipulations(); } Since this event will

Importing a local HTML file/code into a WebBrowser

拜拜、爱过 提交于 2019-12-06 05:28:36
I'm trying to get a local HTML file to display within a WebBrowser in a VB.NET program. I'm using the code below, however it doesn't seem to work, and I can't figure out why: 'first method WebBrowser1.Navigate(@".\index.html"); 'second method HTML = "normal" WebBrowser1.Document.Body.InnerHtml = HTML The first method produces the error "" in the Debug console when I go to run it. If I try it with out the @ , I get an empty white page. If I change the address, however ,so I know its a broken URL, I get a 404 message, which makes it seem like it's finding the file but not rendering it? The

Webbrowser: sequencing activites when no DocumentCompleted is fired by a link on hosted webpage

余生长醉 提交于 2019-12-06 05:24:43
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent; private void button12_Click(object sender, EventArgs e) { checkBox1.Checked = false; //unchecked if the NAvigating event is fired and Checked after DocumentCompleted is fired, only to have a visual reference on the Form HtmlDocument doc = Program.wb.Document; HtmlElement ele = doc.GetElementById("menuTable"); foreach (HtmlElement sub in ele.All) { if (sub.GetAttribute("href").Contains("something")) { ele = sub; break; } } //PHASE 1: clicking on a Web link to navigate to a page that contains other

How can I add an extra http header using IHTTPNegotiate?

混江龙づ霸主 提交于 2019-12-06 05:11:30
问题 How can I add an extra header to the request using IHTTPNegotiate? I added the interface but functions BeginningTransaction & OnResponse never get called. TNameSpaceHandler = class(TComObject, IInternetProtocol, IHttpNegotiate) ... function BeginningTransaction(szURL, szHeaders: LPCWSTR; dwReserved: DWORD; out szAdditionalHeaders: LPWSTR): HResult; stdcall; function OnResponse(dwResponseCode: DWORD; szResponseHeaders, szRequestHeaders: LPCWSTR; out szAdditionalRequestHeaders: LPWSTR): HResult

Get HTML source code from browser control embedded in C#

二次信任 提交于 2019-12-06 05:07:20
I have a browser control embeded in a C# windows app. I want to grab the rendered HTML (which could have been modified by javascript) not the original one. Any suggestions? You can get the HTML, and indeed set it, with WebBrowser.DocumentText . Sheng is correct, DocumentText returns the streamed document before scripts run. His code doesn't compile, but it's essentially correct. I found that you need: mshtml.HTMLDocument doc = webBrowser1.Document.DomDocument as mshtml.HTMLDocument; string html = doc.documentElement.outerHTML; DocumentText internally use the document's IPersistStream interface

WebBrowser Threads don't seem to be closing

南楼画角 提交于 2019-12-06 05:02:21
I am using WebBrowser to render javascript on webpages to scrape the rendered source code, but after several page loads, the CPU usage spikes to 100% as well as the number of threads. I'm assuming that the threads are not closing properly once the webpage has been rendered. I am trying to open the browser, extract the source code, and then close the browser and move to the next page. I am able to get the rendered page, but this program doesn't make it very far before getting bogged down. I tried adding wb.Stop() but that didn't help. The memory doesn't seem to be the problem (stays at a

Catching and handling Web Browser Close Event

北战南征 提交于 2019-12-06 04:41:57
问题 I am Using Windows Forms and a WebBrowser Control, I am in need of catching and handling the WebBrowser Controls call to close. I have looked at this but it is not working as I need it to: http://blogs.artinsoft.net/Mrojas/archive/2009/05/21/Extended-WebBrowser-Control-Series-WebBrowser-Control-and-windowClose().aspx This is the message I get: --------------------------- Web Browser --------------------------- The webpage you are viewing is trying to close the window. Do you want to close

What is a good alternative to the WPF WebBrowser Control?

和自甴很熟 提交于 2019-12-06 04:39:23
问题 I have an MDI WPF app that I need to add web content to. At first, great it looks like I have 2 options built into the framework the Frame control and the WebBrowser control. Given that this is an MDI app it doesn't take long to discover that neither of these will work. The WPF WebBrowser control wraps up the IE WebBrowser ActiveX Control which uses the Win32 graphics pipeline. The "Airspace" issue pretty much sums this up as "Sorry, the layouts will not play nice together". Yes, I have

getting the scroll value from a WebBrowser Control C#

萝らか妹 提交于 2019-12-06 04:13:12
问题 I am trying to get the Y scroll index for a web page in the WebBrowser control but I can't access the values for the built in Scroll bar. Any Ideas? 回答1: For IE in standards mode (with a doctype, as you say) scrollTop is a property of the <html> element, not the <body> : HtmlDocument htmlDoc = this.webBrowser1.Document; int scrollTop = htmlDoc.GetElementsByTagName("HTML")[0].ScrollTop; (A nicer way to get to the <html> element would be good, if anyone knows of one.) 回答2: are you trying to

Delete cookies in webBrowser without restart

心不动则不痛 提交于 2019-12-06 03:40:11
问题 Can you say how I can delete all cookies in private System.Windows.Forms.WebBrowser webBrowser1 . I used [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength); I want do this with button click. private void button1_Click(object sender, EventArgs e) { InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0); } But it doesn't work. And I know about webBrowser1