Hello,
I know similar problems have been posted here before. I know this because I've searched this site for solutions, but the ones I've found haven't worked out for me.
I have a problem with the web browser control. Right now, it renders pages like an old version of Internet Explorer. I need it to render them as Microsoft Edge or Chrome would have. Some of the solutions I found to other people's versions of the same problem include inserting the HTML tag. That did not work for me.
The other solution, which seems to do the trick for a lot of people, is to create a value in the registry database with the name of your application (e.g. myApp.exe) and a integer value representing what Internet Explorer-version you want the web browser control to behave as - the decimal value 10001, apparently, being Edge and 8888 and 9999 being the most recent versions of Internet Explorer.
That's when I wrote this code, which still doesn't work. According to one website, whose url I'm going to provide, the JavaScript member
document.documentMode
should equal 11 for Edge when it works (that is, when the web browser control behaves as Edge due to the 10001 value in the registry database). Needless to say, here documentMode is set to 5, like it completely ignores the registry values I've set. I've created both relative and absolute paths to my EXE (a Visual Studio debug build) in both the 32-bit and 64-bit parts of regedit, and in both HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE. I wasn't allowed to touch the latter with C#. Running my app without administrator privileges threw an exception; with admin privileges it just ignored my attempt to create a value in HKEY_LOCAL_MACHINE.
This is the code I wrote:
public partial class MainForm : Form
{
const string regValue32cu = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
const string regValue64cu = @"HKEY_CURRENT_USER\Software\wow6432node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
const string regValue32lm = @"HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
const string regValue64lm = @"HKEY_LOCAL_MACHINE\Software\wow6432node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
const uint value = 10001U;
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
Microsoft.Win32.Registry.SetValue(
regValue64cu,
@"C:\Users\Thomas\source\C#\regedit\bin\Debug\YouseeLoader.exe",
value,
Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(
regValue64cu,
@"YouseeLoader.exe",
value,
Microsoft.Win32.RegistryValueKind.DWord);
browser.DocumentText = "<script>document.write('Document Mode: ' + document.documentMode);</script>";
}
}
What am I doing wrong? My exe is called YouseeLoader.exe. It is not a part of the PATH environment variable. The goal of my app is to be able to extract the part of
https://tv.yousee.dk/tv-guide[
^] that is being inserted in the
<div id="mount"></div>
element in Edge and Chrome, but not in older versions of Internet Explorer, but for now, I just want the web browser control to render properly like Edge and Chrome.
Thank you in advance,
- Thomas
What I have tried:
Controlling WebBrowser Control Compatibility | Microsoft Docs[
^] (article using document.documentMode with pictures)
internet explorer 8 - How to set FEATURE_BROWSER_EMULATION to IE8 mode? - Stack Overflow[
^] (32- and 64-bit registry keys)
Internet Feature Controls (B..C) (Internet Explorer) | Microsoft Docs[
^] (MSDN article on browser emulation and value description)