C# webbrowser Ajax call





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







34















I am using a webbrowser control embeded in C# WPF .NET4 app. Whenever I press manually the button in a form, the browser hangs on "Your request is being processed" message and nothing happens. If I do the same in full IE browser the page is processed normally producing the results.
What I am missing? Thanks
The code behind the button is the following



<a onclick="startSearch();" href="javascript:void(-1);" name="btnNext" class="btn floatLe noClear btnSubmit btnRight"> 
<span>Continue</span>
</a>









share|improve this question





























    34















    I am using a webbrowser control embeded in C# WPF .NET4 app. Whenever I press manually the button in a form, the browser hangs on "Your request is being processed" message and nothing happens. If I do the same in full IE browser the page is processed normally producing the results.
    What I am missing? Thanks
    The code behind the button is the following



    <a onclick="startSearch();" href="javascript:void(-1);" name="btnNext" class="btn floatLe noClear btnSubmit btnRight"> 
    <span>Continue</span>
    </a>









    share|improve this question

























      34












      34








      34


      34






      I am using a webbrowser control embeded in C# WPF .NET4 app. Whenever I press manually the button in a form, the browser hangs on "Your request is being processed" message and nothing happens. If I do the same in full IE browser the page is processed normally producing the results.
      What I am missing? Thanks
      The code behind the button is the following



      <a onclick="startSearch();" href="javascript:void(-1);" name="btnNext" class="btn floatLe noClear btnSubmit btnRight"> 
      <span>Continue</span>
      </a>









      share|improve this question














      I am using a webbrowser control embeded in C# WPF .NET4 app. Whenever I press manually the button in a form, the browser hangs on "Your request is being processed" message and nothing happens. If I do the same in full IE browser the page is processed normally producing the results.
      What I am missing? Thanks
      The code behind the button is the following



      <a onclick="startSearch();" href="javascript:void(-1);" name="btnNext" class="btn floatLe noClear btnSubmit btnRight"> 
      <span>Continue</span>
      </a>






      c# webbrowser-control






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 20 '13 at 11:07









      JimJim

      1,03442641




      1,03442641
























          2 Answers
          2






          active

          oldest

          votes


















          100














          WebBrowser control (both WPF and WinForms versions) behaves in many ways differently from the full IE. You may want to implement Feature Control to bring its behavior as close to IE as possible (particularly, FEATURE_BROWSER_EMULATION), this often solves the script compatibility issues. Here is some code, note that it does not require admin rights to run:



          private void SetBrowserFeatureControlKey(string feature, string appName, uint value)
          {
          using (var key = Registry.CurrentUser.CreateSubKey(
          String.Concat(@"SoftwareMicrosoftInternet ExplorerMainFeatureControl", feature),
          RegistryKeyPermissionCheck.ReadWriteSubTree))
          {
          key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
          }
          }


          For example:



          private void SetBrowserFeatureControl()
          {
          // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

          // FeatureControl settings are per-process
          var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

          // make the control is not running inside Visual Studio Designer
          if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
          return;

          SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
          SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI ", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
          SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
          SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
          }

          private UInt32 GetBrowserEmulationMode()
          {
          int browserVersion = 7;
          using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftInternet Explorer",
          RegistryKeyPermissionCheck.ReadSubTree,
          System.Security.AccessControl.RegistryRights.QueryValues))
          {
          var version = ieKey.GetValue("svcVersion");
          if (null == version)
          {
          version = ieKey.GetValue("Version");
          if (null == version)
          throw new ApplicationException("Microsoft Internet Explorer is required!");
          }
          int.TryParse(version.ToString().Split('.')[0], out browserVersion);
          }

          UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. Default value for Internet Explorer 11.
          switch (browserVersion)
          {
          case 7:
          mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
          break;
          case 8:
          mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
          break;
          case 9:
          mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
          break;
          case 10:
          mode = 10000; // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode. Default value for Internet Explorer 10.
          break;
          default:
          // use IE11 mode by default
          break;
          }

          return mode;
          }


          You should come up with your own set of features and register them before WebBrowser has initialized, e.g., in the main form constructor:



          public MainWindow()
          {
          SetBrowserFeatureControl();

          InitializeComponent();
          //...
          }


          Updated, I currently use and recommend a set of features that can be found here.






          share|improve this answer





















          • 3





            this is just excelent,,, worked like a charm

            – Jim
            Aug 20 '13 at 12:42






          • 1





            @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

            – noseratio
            Aug 20 '13 at 15:17






          • 1





            Great, thanks everythink working fine

            – Jim
            Aug 21 '13 at 8:44






          • 1





            Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

            – noseratio
            Aug 21 '13 at 10:36








          • 1





            @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

            – ShamilS
            Apr 16 '14 at 16:03



















          -2














          This works for me:yourWebBrowser.ScriptErrorsSuppressed = true;






          share|improve this answer
























            protected by Community Aug 1 '18 at 15:47



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?














            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            100














            WebBrowser control (both WPF and WinForms versions) behaves in many ways differently from the full IE. You may want to implement Feature Control to bring its behavior as close to IE as possible (particularly, FEATURE_BROWSER_EMULATION), this often solves the script compatibility issues. Here is some code, note that it does not require admin rights to run:



            private void SetBrowserFeatureControlKey(string feature, string appName, uint value)
            {
            using (var key = Registry.CurrentUser.CreateSubKey(
            String.Concat(@"SoftwareMicrosoftInternet ExplorerMainFeatureControl", feature),
            RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
            key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
            }
            }


            For example:



            private void SetBrowserFeatureControl()
            {
            // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

            // FeatureControl settings are per-process
            var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

            // make the control is not running inside Visual Studio Designer
            if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
            return;

            SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
            SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
            }

            private UInt32 GetBrowserEmulationMode()
            {
            int browserVersion = 7;
            using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftInternet Explorer",
            RegistryKeyPermissionCheck.ReadSubTree,
            System.Security.AccessControl.RegistryRights.QueryValues))
            {
            var version = ieKey.GetValue("svcVersion");
            if (null == version)
            {
            version = ieKey.GetValue("Version");
            if (null == version)
            throw new ApplicationException("Microsoft Internet Explorer is required!");
            }
            int.TryParse(version.ToString().Split('.')[0], out browserVersion);
            }

            UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. Default value for Internet Explorer 11.
            switch (browserVersion)
            {
            case 7:
            mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
            break;
            case 8:
            mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
            break;
            case 9:
            mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
            break;
            case 10:
            mode = 10000; // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode. Default value for Internet Explorer 10.
            break;
            default:
            // use IE11 mode by default
            break;
            }

            return mode;
            }


            You should come up with your own set of features and register them before WebBrowser has initialized, e.g., in the main form constructor:



            public MainWindow()
            {
            SetBrowserFeatureControl();

            InitializeComponent();
            //...
            }


            Updated, I currently use and recommend a set of features that can be found here.






            share|improve this answer





















            • 3





              this is just excelent,,, worked like a charm

              – Jim
              Aug 20 '13 at 12:42






            • 1





              @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

              – noseratio
              Aug 20 '13 at 15:17






            • 1





              Great, thanks everythink working fine

              – Jim
              Aug 21 '13 at 8:44






            • 1





              Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

              – noseratio
              Aug 21 '13 at 10:36








            • 1





              @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

              – ShamilS
              Apr 16 '14 at 16:03
















            100














            WebBrowser control (both WPF and WinForms versions) behaves in many ways differently from the full IE. You may want to implement Feature Control to bring its behavior as close to IE as possible (particularly, FEATURE_BROWSER_EMULATION), this often solves the script compatibility issues. Here is some code, note that it does not require admin rights to run:



            private void SetBrowserFeatureControlKey(string feature, string appName, uint value)
            {
            using (var key = Registry.CurrentUser.CreateSubKey(
            String.Concat(@"SoftwareMicrosoftInternet ExplorerMainFeatureControl", feature),
            RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
            key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
            }
            }


            For example:



            private void SetBrowserFeatureControl()
            {
            // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

            // FeatureControl settings are per-process
            var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

            // make the control is not running inside Visual Studio Designer
            if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
            return;

            SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
            SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
            }

            private UInt32 GetBrowserEmulationMode()
            {
            int browserVersion = 7;
            using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftInternet Explorer",
            RegistryKeyPermissionCheck.ReadSubTree,
            System.Security.AccessControl.RegistryRights.QueryValues))
            {
            var version = ieKey.GetValue("svcVersion");
            if (null == version)
            {
            version = ieKey.GetValue("Version");
            if (null == version)
            throw new ApplicationException("Microsoft Internet Explorer is required!");
            }
            int.TryParse(version.ToString().Split('.')[0], out browserVersion);
            }

            UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. Default value for Internet Explorer 11.
            switch (browserVersion)
            {
            case 7:
            mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
            break;
            case 8:
            mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
            break;
            case 9:
            mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
            break;
            case 10:
            mode = 10000; // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode. Default value for Internet Explorer 10.
            break;
            default:
            // use IE11 mode by default
            break;
            }

            return mode;
            }


            You should come up with your own set of features and register them before WebBrowser has initialized, e.g., in the main form constructor:



            public MainWindow()
            {
            SetBrowserFeatureControl();

            InitializeComponent();
            //...
            }


            Updated, I currently use and recommend a set of features that can be found here.






            share|improve this answer





















            • 3





              this is just excelent,,, worked like a charm

              – Jim
              Aug 20 '13 at 12:42






            • 1





              @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

              – noseratio
              Aug 20 '13 at 15:17






            • 1





              Great, thanks everythink working fine

              – Jim
              Aug 21 '13 at 8:44






            • 1





              Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

              – noseratio
              Aug 21 '13 at 10:36








            • 1





              @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

              – ShamilS
              Apr 16 '14 at 16:03














            100












            100








            100







            WebBrowser control (both WPF and WinForms versions) behaves in many ways differently from the full IE. You may want to implement Feature Control to bring its behavior as close to IE as possible (particularly, FEATURE_BROWSER_EMULATION), this often solves the script compatibility issues. Here is some code, note that it does not require admin rights to run:



            private void SetBrowserFeatureControlKey(string feature, string appName, uint value)
            {
            using (var key = Registry.CurrentUser.CreateSubKey(
            String.Concat(@"SoftwareMicrosoftInternet ExplorerMainFeatureControl", feature),
            RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
            key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
            }
            }


            For example:



            private void SetBrowserFeatureControl()
            {
            // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

            // FeatureControl settings are per-process
            var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

            // make the control is not running inside Visual Studio Designer
            if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
            return;

            SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
            SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
            }

            private UInt32 GetBrowserEmulationMode()
            {
            int browserVersion = 7;
            using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftInternet Explorer",
            RegistryKeyPermissionCheck.ReadSubTree,
            System.Security.AccessControl.RegistryRights.QueryValues))
            {
            var version = ieKey.GetValue("svcVersion");
            if (null == version)
            {
            version = ieKey.GetValue("Version");
            if (null == version)
            throw new ApplicationException("Microsoft Internet Explorer is required!");
            }
            int.TryParse(version.ToString().Split('.')[0], out browserVersion);
            }

            UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. Default value for Internet Explorer 11.
            switch (browserVersion)
            {
            case 7:
            mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
            break;
            case 8:
            mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
            break;
            case 9:
            mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
            break;
            case 10:
            mode = 10000; // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode. Default value for Internet Explorer 10.
            break;
            default:
            // use IE11 mode by default
            break;
            }

            return mode;
            }


            You should come up with your own set of features and register them before WebBrowser has initialized, e.g., in the main form constructor:



            public MainWindow()
            {
            SetBrowserFeatureControl();

            InitializeComponent();
            //...
            }


            Updated, I currently use and recommend a set of features that can be found here.






            share|improve this answer















            WebBrowser control (both WPF and WinForms versions) behaves in many ways differently from the full IE. You may want to implement Feature Control to bring its behavior as close to IE as possible (particularly, FEATURE_BROWSER_EMULATION), this often solves the script compatibility issues. Here is some code, note that it does not require admin rights to run:



            private void SetBrowserFeatureControlKey(string feature, string appName, uint value)
            {
            using (var key = Registry.CurrentUser.CreateSubKey(
            String.Concat(@"SoftwareMicrosoftInternet ExplorerMainFeatureControl", feature),
            RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
            key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
            }
            }


            For example:



            private void SetBrowserFeatureControl()
            {
            // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

            // FeatureControl settings are per-process
            var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

            // make the control is not running inside Visual Studio Designer
            if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
            return;

            SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
            SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
            SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
            SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
            }

            private UInt32 GetBrowserEmulationMode()
            {
            int browserVersion = 7;
            using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftInternet Explorer",
            RegistryKeyPermissionCheck.ReadSubTree,
            System.Security.AccessControl.RegistryRights.QueryValues))
            {
            var version = ieKey.GetValue("svcVersion");
            if (null == version)
            {
            version = ieKey.GetValue("Version");
            if (null == version)
            throw new ApplicationException("Microsoft Internet Explorer is required!");
            }
            int.TryParse(version.ToString().Split('.')[0], out browserVersion);
            }

            UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. Default value for Internet Explorer 11.
            switch (browserVersion)
            {
            case 7:
            mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
            break;
            case 8:
            mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
            break;
            case 9:
            mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
            break;
            case 10:
            mode = 10000; // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode. Default value for Internet Explorer 10.
            break;
            default:
            // use IE11 mode by default
            break;
            }

            return mode;
            }


            You should come up with your own set of features and register them before WebBrowser has initialized, e.g., in the main form constructor:



            public MainWindow()
            {
            SetBrowserFeatureControl();

            InitializeComponent();
            //...
            }


            Updated, I currently use and recommend a set of features that can be found here.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 29 '18 at 1:23

























            answered Aug 20 '13 at 11:35









            noserationoseratio

            46.3k14124328




            46.3k14124328








            • 3





              this is just excelent,,, worked like a charm

              – Jim
              Aug 20 '13 at 12:42






            • 1





              @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

              – noseratio
              Aug 20 '13 at 15:17






            • 1





              Great, thanks everythink working fine

              – Jim
              Aug 21 '13 at 8:44






            • 1





              Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

              – noseratio
              Aug 21 '13 at 10:36








            • 1





              @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

              – ShamilS
              Apr 16 '14 at 16:03














            • 3





              this is just excelent,,, worked like a charm

              – Jim
              Aug 20 '13 at 12:42






            • 1





              @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

              – noseratio
              Aug 20 '13 at 15:17






            • 1





              Great, thanks everythink working fine

              – Jim
              Aug 21 '13 at 8:44






            • 1





              Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

              – noseratio
              Aug 21 '13 at 10:36








            • 1





              @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

              – ShamilS
              Apr 16 '14 at 16:03








            3




            3





            this is just excelent,,, worked like a charm

            – Jim
            Aug 20 '13 at 12:42





            this is just excelent,,, worked like a charm

            – Jim
            Aug 20 '13 at 12:42




            1




            1





            @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

            – noseratio
            Aug 20 '13 at 15:17





            @Jim, I've added a check for "XDesProc.exe" (VS XAML Designer process), you may want to update your code too.

            – noseratio
            Aug 20 '13 at 15:17




            1




            1





            Great, thanks everythink working fine

            – Jim
            Aug 21 '13 at 8:44





            Great, thanks everythink working fine

            – Jim
            Aug 21 '13 at 8:44




            1




            1





            Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

            – noseratio
            Aug 21 '13 at 10:36







            Hmm, hard to tell what's causing it, but I'd again go through the list of all available options and play with those which look related, trying both 1 and 0 values. E.g., FEATURE_AJAX_CONNECTIONEVENTS, FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_WINDOW_RESTRICTIONS, FEATURE_TABBED_BROWSING etc. Let us know if you find it :)

            – noseratio
            Aug 21 '13 at 10:36






            1




            1





            @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

            – ShamilS
            Apr 16 '14 at 16:03





            @Noseratio: Great code. Thank you. FYI: SetBrowserFeatureControlKey("FEATURE_NINPUT_LEGACYMODE", fileName, 0) blocks setting mouse cursor by mouse-clicking inside WebBrowser control navigated web pages' text boxes. Windows 8. IE10.0.9200.16750, update: 10.0.12

            – ShamilS
            Apr 16 '14 at 16:03













            -2














            This works for me:yourWebBrowser.ScriptErrorsSuppressed = true;






            share|improve this answer






























              -2














              This works for me:yourWebBrowser.ScriptErrorsSuppressed = true;






              share|improve this answer




























                -2












                -2








                -2







                This works for me:yourWebBrowser.ScriptErrorsSuppressed = true;






                share|improve this answer















                This works for me:yourWebBrowser.ScriptErrorsSuppressed = true;







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 1 '18 at 16:08

























                answered Aug 1 '18 at 15:46









                C. DraghiciC. Draghici

                73




                73

















                    protected by Community Aug 1 '18 at 15:47



                    Thank you for your interest in this question.
                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                    Would you like to answer one of these unanswered questions instead?



                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks