24

I keep getting a script error when trying to load the page using webBrowser.Navigate("https://home.nest.com/"). It will pull up fine from my normal internet browser but not in my program.

Can anyone point me in the right direction?

Script Error

8
  • 3
    Post the script that the error references on line 358. We aren't mind readers, we can't tell what's wrong without seeing the code. Commented May 20, 2016 at 15:58
  • [1]: i.sstatic.net/ayNI2.png Commented May 20, 2016 at 16:06
  • Do you already try webBrowser.ScriptErrorsSuppressed = true; ? Commented May 20, 2016 at 16:10
  • yes and the page does not load. Commented May 20, 2016 at 16:11
  • 1
    i am new to all of this learning through trial and error so if I ask a question incorrectly please don't bite my head off.....Dgibbs. Commented May 20, 2016 at 16:12

6 Answers 6

24

as this link answer:

you must only add this line:

webBrowser.ScriptErrorsSuppressed = true;
Sign up to request clarification or add additional context in comments.

3 Comments

This worked for me. I am using vs 2017 with .net framework 4.6.1
SPA-based web pages simply won't render properly.
Nop! The word "Script Error Suppression", expresses itself! It suppresses scripts! It's like you ignore a problem not resolve it. This actually helps to not see that annoying "Error Message" dialog boxes; however, it prevents scripts to be running, hence, the page won't be loading properly.
14

The script errors happen all of the time in the integrated Internet Explorer WebBrowser control even when it's using version 11. Modern websites rely heavily on massive Javascript files and dynamic rendering. You can see that just by watching that page load in a regular browser. The control just can't cut it some of the times.

You might want to try some alternative browser controls. There are no guarantees that it will work with any of them, but at least it's something to try.

  • Awesomium : Originally based on Chromium. I don't know if they still integrate Chromium changes or if they've gone in their own direction. It's free for personal use as well as commercial making less than $100k.
  • DotNetBrowser : Embed a Chromium-based WPF / WinForms component into your .NET application to display modern web pages built with HTML5, CSS3, JavaScript, Silverlight etc.
  • geckofx : An open-source component for embedding Mozilla Gecko (Firefox) in .NET applications.
  • Xilium.CefGlue : A .NET/Mono binding for The Chromium Embedded Framework (CEF) by Marshall A. Greenblatt.
  • BrowseEmAll : BrowseEmAll.Cef (Chrome), BrowseEmAll.Gecko (Firefox), BrowseEmAll Core API (Chrome,Firefox,IE - COMMERCIAL)

There are probably others, but this should give you a start with some of the more popular active projects if you want to pursue this route.

1 Comment

@imrdnck You're welcome. It's unfortunate that the framework browser doesn't work even though it uses IE11, but there's nothing we can really do except go to people dedicated to making a functional replacement. :-)
8

The WebBrowser control is capable of rendering most web pages, but by default it attempts to render pages in compatibility mode (pretty much IE7, hence the issues). If you are building your own page, it's simple, just add the following tag to the header and it should render fine...

<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

However, if you are trying to render a third party site you cannot add tags to, things get more difficult. As mentioned above, you can use a registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION) if it's just on your own machine.

If neither of these options are a possible solution, using a different browser control (again, great suggestions above) is pretty much your only option.

There's a great blog on controlling the browser control compatibility mode at https://learn.microsoft.com/en-gb/archive/blogs/patricka/controlling-webbrowser-control-compatibility

Comments

0

You should add your program name to the register HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION for using the latest feature as same as your normal internet browser.

as for me, value 8000 (0x1F40) - IE8 mode can solve many script error problem.

Ref:

Use latest version of Internet Explorer in the webbrowser control

Comments

0
  private void Form1_Load(object sender, EventArgs e)
  {
            var appName = Process.GetCurrentProcess().ProcessName + ".exe";
            SetIE8KeyforWebBrowserControl(appName);

            webBrowser1.ScriptErrorsSuppressed = true;
  }



private void SetIE8KeyforWebBrowserControl(string appName)
{
     RegistryKey Regkey = null;
     try
     {
         // For 64 bit machine
         if (Environment.Is64BitOperatingSystem)
              Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
         else  //For 32 bit machine
               Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);

          // If the path is not correct or
          // if the user haven't priviledges to access the registry
          if (Regkey == null)
          {
              MessageBox.Show("Application Settings Failed - Address Not found");
              return;
          }

          string FindAppkey = Convert.ToString(Regkey.GetValue(appName));

          // Check if key is already present
          if (FindAppkey == "8000")
          {
              MessageBox.Show("Required Application Settings Present");
              Regkey.Close();
              return;
          }

          // If a key is not present add the key, Key value 8000 (decimal)
          if (string.IsNullOrEmpty(FindAppkey))
              Regkey.SetValue(appName, unchecked((int)0x1F40), RegistryValueKind.DWord);

           // Check for the key after adding
           FindAppkey = Convert.ToString(Regkey.GetValue(appName));

           if (FindAppkey == "8000")
               MessageBox.Show("Application Settings Applied Successfully");
           else
               MessageBox.Show("Application Settings Failed, Ref: " + FindAppkey);
       }
       catch (Exception ex)
       {
           MessageBox.Show("Application Settings Failed");
           MessageBox.Show(ex.Message);
       }
       finally
       {
           // Close the Registry
           if (Regkey != null)
               Regkey.Close();
       }
   }

1 Comment

It would be nice if you give some explanation to your code
0

You may even set the registry value to 11000 to have the latest version of IE!!

1 Comment

where is th registery parameter?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.