Allowing javascript to run on a windows form web browser
Asked Answered
R

2

21

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;

Error in Web Browser

Rank answered 5/8, 2014 at 15:25 Comment(0)
R
27

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 version of Internet Explorer is not enough and you must explicitly specify the version of IE to use by adding a new registry key.

HTML fix;

<!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
    ... other headers
  </head>
  <body>
    ... content
  </body>
</html>  

Via registry;

Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION for 64-bit or 32-bit only machines.

Or go to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION for 32-bit on 64-bit systems (It cannot hurt to add keys to both locations if you have them. If you do not have them, you can make the folders yourself).

Create a new DWORD key and name it the name of your application e.g. "myapp.exe" and then edit the value of the key. There are many different values you can add depending on the IE version you want to emulate. I entered 11001 (as a decimal value - 0x2AF9 in HEX) which emulates IE 11 (many more values located at: http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx#browser_emulation).

If you're using Visual Studio like I am, you'll notice that this method might not even work. However, it does work. You need to manually open the .exe file using Explorer or terminal rather than run the project on Visual Studio.

If you wish to run the program on Visual Studio then consider adding a key for "myapp.vshost.exe" as this is used for debugging.

More information and source is from; http://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version.

I hope this helps anyone with any issue regarding your Web Browser perhaps using the wrong IE version as a wrapper or functions are not working as intended.

Rank answered 5/8, 2014 at 16:2 Comment(1)
i was so stuck. Especially since i set the browser control to suppress error messages. All I was getting was a blank screen. Now the IE emulator is updated, my browser control is working again. The target must have updated their javascript. U R LEGEND.Ops
P
17
 <!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
    ... other headers
  </head>
  <body>
    ... content
  </body>
</html>  

This will work out , This is the summery of Ryan Singh's answer

Pilar answered 11/9, 2016 at 8:56 Comment(2)
Perfect #2, tks!!Nystagmus
Wayhay! Why is this not the accepted answer? Splendid.Dalpe

© 2022 - 2024 — McMap. All rights reserved.