none
Webbrowser from C# code - object doesn't support property or method 'bind' RRS feed

  • Question

  • Hello,

    I am building a .NET application, in which I would like to open a browser in a form and browse a specific site. I do not administer the site, it is a 3rd party application, so I am unable to edit the webapplication I am browsing.

    I use IE 11, the newest version.

    I use .NET framework 4.5

    I use Visual Studio 2013 Ultimate.

    I get the following error when browsing it: object doesn't support property or method 'bind'

    The error happens in the 51degrees.js which is used on the site, specifically this line:

    window.attachEvent("beforeunload", this.unloadBegin.bind(this), true);

    Other Javascript files loaded on the site:

    bootstrap.min.js
    jquery-1.9.0.min.js
    jquery.cookie.js
    common.js

    I am not getting this error when browsing the site normally (not through the .NET application.

    From what I can tell, from other posts on the subject, it is the way jQuery is handled by IE.

    Any ideas on what I can do?

    Again, I cannot edit the webapplication, only the .NET application.

    Thanks in advance,

    Jacob.



    • Edited by Jacmarpet Tuesday, September 22, 2015 1:22 PM
    Tuesday, September 22, 2015 1:21 PM

Answers

  • Try an experiment: access the Website using Internet Explorer, then press <F12> to show Developer Tools, go to Emulation tab and change the Document Mode to “7”.

    You just simulated the default behavior of WebBrowser control. Do you receive the same errors? Then consider the next aspects.

    “7” is the default mode used by WebBrowser control. In order to increase the version and use the modern engine, add FEATURE_BROWSER_EMULATION values to the Registry:

    Such values can be added manually (using RegEdit tool) or programmatically before showing the first WebBrowser. Note that there are separate keys for 32- and 64-bit applications. Additionally, the name of added key should be “xxxx.vshost.exe” instead of “xxxx.exe” if the program is tested with Visual Studio.

    (By the way, ‘window.attachEvent’ is described in documentation as unsupported. Probably it is re-defined by some JavaScript code).

    Tuesday, September 22, 2015 5:09 PM