JavaScript not executing in a .NET WebBrowser control

Two of my friends tested a project that I was working on that uses a WebBrowser control and ran into a constant scenario in which a WebBrowser control could not execute any JavaScript on the contained web page.

To narrow it down, I created a new Windows Forms project that contains only the WebBrowser control and is trying to go to the following page: http://javatester.org/javascript.html

The result on my friends computer was lower (click to enlarge):

Control render

As you can see, when you try to call special JS code, it doesn’t turn to anything, otherwise, if you view it in a web browser with JS disabled or disabled, you will see something.

He exported his registry keys containing parameters for the included JavaScript (see https://gist.github.com/4699943 ), and the value for 1400 in each of the keys corresponds to the same settings that I use, and when I run the program I have no problem.

The code for the entire test project is as follows:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Shown(object sender, EventArgs e) { this.webBrowser1.Navigate("http://javatester.org/javascript.html"); } } } 

If a new project is created using this code that targets structure 4.5 (either on my machine or on it), it works, however, if it is created using 4.0 or lower, the result is higher. I am not sure if this is a coincidence or if it is really something related to the problem / solution.

It should be noted that if he goes to this page in Internet Explorer, there is no problem, he discovers that JavaScript is enabled, this problem is found exclusively in this test application and in the main project of which he is a part.

Any help would be appreciated, I spent two months trying to figure it out and still can't.

+10
source share
2 answers

From my tests, WebBrowser with .NET 4 reports the IE 7.0 web browser agent string. So first check if JavaScript is working correctly in IE7.

0
source

Scripts do not load if you use the webbrowser control. The Text property of the document. This is great using the navigation method. I need a document text property to work as I get html from a third party. The same html content works fine if I create an html file from it and open it in a regular IE browser. The web browser control does not work.

-one
source

All Articles