"JSON" - undefined

I am trying to load a Chromecast background website into aC # WebBrowser , but I get: enter image description here

I assumed this is happening because the webbrowser uses IE7 by default (?), Which may not work well with JS on the website. I tried updating the FEATURE_BROWSER_EMULATION register to 9000, hoping to get the webbrowser use the IE9 platform. But I still get the same errors.

Is webbrowser basic for this task or is there a way to solve this problem?

EDIT:

So, when I print webbrowser.version , I get: Version: 11.0.9600.16518. What current version of IE do I have. If I open IE11 and go to the URL, its work will be great. I do not know why a problem with webbroswer occurs.

I tried injecting JSON Parser into a webpage using this code:

 HtmlDocument doc = webBrowser1.Document; Console.WriteLine(doc); HtmlElement head = doc.GetElementsByTagName("head")[0]; HtmlElement s = doc.CreateElement("script"); s.SetAttribute("type", "text/javascript"); s.SetAttribute("src", "http://192.168.1.23:10000/JSON-js-master/json2.js"); head.AppendChild(s); 

I tried using local and external ips referring to the host file. It seems the difference has not changed.

+2
source share
1 answer

Apparently, when the WebBrowser control starts, it starts in the version of IE installed on the computer, but it works in IE7 compatibility mode. Downloading the link you provided requires a more modern browser. Essentially, the requested page requires IE10 or higher.

You need to change the browser emulation settings in the registry so that WebBrowser users use a more modern set of IE functions:

Internet feature management

As you said in your question, there are two areas in the registry that you need to configure:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BROWSER_EMULATION

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BROWSER_EMULATION

In each of these two places, the process name of your applications is included in the DWORD value set indicating the compatibility level. Specific values ​​are on the Manage Internet Features help page. The file names are the name of your application "MyApplication1.exe", or if you are working in Visual Studio, this is "MyApplication1.vshost.exe".

Since I have IE 11 installed, I set the browser emulation setting to 11001 and worked on your linked web page.

+4
source

Source: https://habr.com/ru/post/1274991/


All Articles