webbrowser-control

Allowing javascript to run on a windows form web browser

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:02:24
I want to use a Web Browser to access a website that uses JavaScript on load. I understand that Web Browser is a wrapper of the current installed version of Internet Explorer. However, testing the website on Internet Explorer yields no errors but does not work if I use the Web Browser to access the content. I have also looked at my internet security settings to ensure it is enabled. The issue I get is; Awkwardly enough, I found the answer moments after posting this but I thought anyone who comes across the same problem as me will find solace in this answer; It seems downloading the latest

WebBrowser: Drag&Drop

我与影子孤独终老i 提交于 2019-11-28 04:23:54
问题 I want to intercept drag&drop action on WebBrowser control. To be more precise, I want to be able to cancel or approve drag&drop event based on file extension (and process that file outside WebBrowser) and I want to make drag&drop icon look like regular icon: http://snag.gy/DUjMc.jpg, not like this one: http://snag.gy/ExX19.jpg. I believe for this I need to implement custom IDocHostUIHandler and intercept GetDropTarget. Unfortunately, I have no success in doing that. I am using this code as

Disable image loading from webbrowser control before the documentcompleted event

北城余情 提交于 2019-11-28 03:57:31
问题 I want to prevent images in a page from being loaded in the WebBrowser control. I want it to happen before the DocumentCompleted event occurs. Is there a way to do this? 回答1: You can set the DISPID_AMBIENT_DLCONTROL ambient property or change the browser's process's WinInet session to use a programmable proxy. 回答2: Try this code: RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true); RegKey.SetValue("Display Inline Images", "no"); It changes

Getting the page height from a WinForms WebBrowser control

筅森魡賤 提交于 2019-11-28 03:42:44
问题 I've been trying for the last few days to get the height of a web page from the Document property of a WebBrowser control. Here's my latest attempt. HtmlElementCollection children = webBrowser.Document.All; int maxOffset = 0; foreach (HtmlElement child in children) { int bottom = 0; bottom = child.OffsetRectangle.Bottom; if (bottom > maxOffset) { maxOffset = bottom; pageHeight = maxOffset; } } I've tried to work out the max height of the page by finding the offset bottom of the lowest element

How to enable inPrivate mode in the WebBrowser control

时光总嘲笑我的痴心妄想 提交于 2019-11-28 02:59:50
问题 I have to make a IE type browser with some extra features on it. In Visual Studio, we have a component named "WebBrowser" that uses current IE browser installed in user's pc. However, I am unable to find any property that enables access to the InPrivate mode I hoped would be exposed by control. Is there a way to use InPrivate mode with the WebBrowser control, or would I have to make my own browser that supports this? 回答1: According to EricLaw's answers on a related question, it sounds like

WPF WebBrowser and special characters like german “umlaute”

我只是一个虾纸丫 提交于 2019-11-28 02:17:32
问题 I use the WPF WebBrowser Control in my app. I have a file (mht) which contains german umlaute (ä ö ü). Now, I load this this file with .Navigate(path) but the Problem is, that this charactes are not shown correct. How can I solve this? Best Regards, Thomas 回答1: This is very quirky. My solution was to put an explicit meta tag in my HTML file - "My Page.html" <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'> Then using the standard Web Browser .NET control I then created a URI

Run and control browser control in different thread

北城余情 提交于 2019-11-28 02:17:26
I have my main gui class with some subclassess. There are +- 3 threads that are collecting data from various internet sources and API gateways etc. Now, out of one of these threads, I want to run a webbrowser control, so I can add some autobrowsing functionality to my program. Each of the sub threads should be capable of opening a webbrowser on its own. So I created a second c# windows form, which contains only the webbrowsing control. I already use the ApartmentState.STA setting on this new thread for the webbrowser control. However, the form2 is unresponsive. I tried to call Application.Run(

Open new web page in new tab in WebBrowser control

拜拜、爱过 提交于 2019-11-28 02:15:45
I'm using WebBrowser control in my c# application, and I want to open web pages in it. It's completely done. My problem: Any link in the web page that its target is _blank will open in new IE Window. I'd like to open such link in new tab in my application. How to do it? Thanks! private void Browser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { var webBrowser = (WebBrowser)sender; if (webBrowser.Document != null) { foreach (HtmlElement tag in webBrowser.Document.All) { if (tag.Id == null) { tag.Id = String.Empty; switch (tag.TagName.ToUpper()) { case "A": { tag.MouseUp

WebBrowser control in a class library

喜欢而已 提交于 2019-11-28 01:58:31
问题 So as the title suggests, I'm trying to use WebBrowser control in a class library. I've gone through several SO questions like this excellent post, but the unique thing in my situation is that the WebBrowser object must remain alive for the life of application and keep its state/cookies across different calls that the library clients will make from time to time. I have confirmed that WebBrowser control does not do navigation unless the thread it was created on contains a message pump. But as

Set Value of a TextArea inside a WebBrowser Control (C# / .NET)

旧巷老猫 提交于 2019-11-28 01:58:24
问题 I'm looking to set the value of a TextArea using the .NET WebBrowser Control. I have been able to set the values of textboxes using the following code (replace "username" with the name of the texbox): webBrowser1.Document.All.GetElementsByName("username")[0].SetAttribute("Value", "SomeUser"); I tried using similar code on a TextArea (using GetElementById) and failed to remember that TextArea input types do not contain a "Value" attribute. I have also tried setting the InnerHtml and InnerText