webbrowser-control

WebBrowser.Document.Body is always null

ⅰ亾dé卋堺 提交于 2019-12-04 03:17:51
I have a WebBrowser document set to be in edit mode. I am trying to manipulate the inner text of the body element by using WebBrowser.Document.Body.InnerText , however, WebBrowser.Document.Body remains null. Here is the code where I create the document contents: private WebBrowser HtmlEditor = new WebBrowser(); public HtmlEditControl() { InitializeComponent(); HtmlEditor.DocumentText = "<html><body></body></html>"; myDoc = (IHTMLDocument2)HtmlEditor.Document.DomDocument; myDoc.designMode = "On"; HtmlEditor.Refresh(WebBrowserRefreshOption.Completely); myContentsChanged = false; } I can edit

Fragment (anchor #) in .NET 4 WebBrowser Control getting lost with Adobe PDF Reader and file://

烈酒焚心 提交于 2019-12-04 01:50:47
问题 I create an URI with a fragment (aka anchor #). UriBuilder ub = new UriBuilder("file://path/doc.pdf"); ub.Fragment = "chapterX"; The url is shown correctly in the debugger (ub -> file://path/doc.pdf#chapterX ). But when I assign it to a WebBrowser control, the fragment part gets lost (reason for the fragment see PDF Open parameter). this._myWebBrowser.Url = ub.Uri; // Alternative this._myWebBrowser.Navigate("file://path/doc.pdf#chapterX"); When I check this._myWebBrowser.Url it displays file:

'JSON' is undefined

99封情书 提交于 2019-12-04 01:44:54
问题 I'm trying to load the Chromecast background website into a c# WebBrowser but am getting: I assumed it was happening because the webbrowser is using IE7 by default(?) which might not play well with the JS in the website. I tried to updated the registery FEATURE_BROWSER_EMULATION to 9000 hoping force the webbrowser to use IE9 framework. But I still get the same errors. Is the webbrowser to basic for this task or is there a way around this problem? EDIT: So when I print the webbrowser.version I

WebBrowser Control DocumentCompleted after iframe & Javascript completion

蓝咒 提交于 2019-12-03 22:15:29
I need to capture an image of generated HTML. I'm using Alex Filipovici's excellent solution from here: Convert HTML string to image . It works great except when I'm trying to load a page that has an iframe that uses some Javascript to load. static int width = 1024; static int height = 768; public static void Capture() { var html = @" <!DOCTYPE html> <meta http-equiv='X-UA-Compatible' content='IE=Edge'> <html> <iframe id='forecast_embed' type='text/html' frameborder='0' height='245' width='100%' src='http://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston'> </iframe> </html> ";

Set Proxy Credential in Web Browser Control

ぐ巨炮叔叔 提交于 2019-12-03 21:52:01
I am working on a legacy code where an application uses AxSHDocVw.AxWebBrowser ( not System.Windows.Forms.Control ) to open up web pages and am extending it to take proxy into considerations. I have following example on http://www.pinvoke.net/default.aspx/wininet/internetsetoption.html to use InternetSetOption() to go through specified proxy and tested that it works. Now the hurdle is I tried everything but failed to pass username and password with following code: //-- Set Proxy Username bool resultF = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY_USERNAME, username, username.Length+1);

WebBrowser control crashes on Windows 10

六眼飞鱼酱① 提交于 2019-12-03 21:17:41
The following short code example demonstrates WebBrowser crashing for some pages. The problem started after a fresh installation of Windows 10 and Visual Studio Community 2015 on 26-27 December 2015. The problem did not occur with the previous installation of Windows 10 and Visual Studio Community 2015. The same program has been tested on another computer with the same software and operating system and the same problem occurs. Clicking 'Download 2' successfully downloads the page from Google. Clicking 'Download 1' starts downloading from Bloomberg and after most of the page is visible a popup

WebBrowser Control and Adobe Flash content

Deadly 提交于 2019-12-03 21:09:28
I have a standard WebBrowser Control that has been modified to use IE11 in Edge Mode ( see here for details for how I did that ). I am unable to play Flash content on some websites, a notable one being BBC iPlayer and other media requiring Flash served on the BBC website, for which I receive the following error: There was a problem initialising the player. Script access is denied in your browser. I am able to view this content using Internet Explorer, and script access is enabled within IE. Errors are suppressed in the WebBrowser control by setting ScriptErrorsSuppressed property to true, even

WebBrowser control: “Specified cast is not valid.”

江枫思渺然 提交于 2019-12-03 20:33:13
I used a WebBrowser control to navigate to the login page for a WordPress blog. The page loads fine but whenever I try to access the WebBrowser from a thread. I get a specific cast is not valid exception. Also when debugging, everything freezes up for around 5 seconds. When debugging and I try to access the control. I get timed out errors on all of the member variables. //in constructor of main form Thread.CurrentThread.ApartmentState = ApartmentState.STA; this.CheckForIllegalCrossThreadCalls = false; mainThreadHandle = new Thread(mainThread); mainThreadHandle.Start(); private void mainThread(

What can i do about : Enter username and password for “” at http://localhost in Firefox browser?

蹲街弑〆低调 提交于 2019-12-03 20:30:17
Some times when i want to run and debug my asp.net projects and see it on Firefox browser, i see a window that ask me Username and Password for http://localhost IIS. I find this solution and think maybe is useful for others. So decide to share it with you. Open firefox and type in the address bar about:config type ntlm in the textbox. Double click on network.automatic-ntlm-auth.trusted-uris and type localhost there. Click on OK. You are done. Open firefox and type in the address bar about:config type ntlm in the textbox. Double click on network.automatic-ntlm-auth.trusted-uris and type

How can I prevent a user from browsing to certain web sites in a WebBrowser control?

别等时光非礼了梦想. 提交于 2019-12-03 20:19:14
I have a simple web browser embedded in an application that allows a user to search Wikipedia, and I'm trying to prevent the user from browsing to other websites outside wikipedia (e.g. by clicking an external link the references). Right now, I'm using this simple code: this.textBoxAddress.Text = this.webBrowser.Url.ToString(); if (this.webBrowser.Url.Host != "en.wikipedia.org") { this.webBrowser.Visible = false; this.labelErrorMessage.Visible = true; } else { this.webBrowser.Visible = true; this.labelErrorMessage.Visible = false; } This code works, except the page is already loaded when it's