简体   繁体   中英

Getting an error with a web browser control in a WinForms Application

I am trying to use a webbrowser control in a winforms app. In my app, when I try to navigate to places that work fine in IE or Chrome, I get a "Script Error" window stating that "An error has ocurred in the script on this page." with "Error: Object doesn't support this property or method." Yet, I can still use IE to get to the page without issue.

What am I missing?

The script error is less important to me than the fact that it is behaving differently in my app than it does in a web browser. My question is this:

Is it possible to embed a web browser in a .Net application that will behave exactly like a stand-alone web browser? How?

For posterity: I know this isn't a proper fix, but you can actually open up Internet Explorer -> Tools -> Internet Options -> Advanced then look under Browsing for the options Disable script debugging (Internet Explorer & Other). Deselect those and you will solve the problem.

Another option is like this:

            webBrowser1.ScriptErrorsSuppressed = true;

IE probably has the error messages turned off. There is likely a script error that needs resolved.

If this is anything like the using webbrowser control in WinMo, make sure you call InitHTMLControl. Also, in code I've written (webbrowser in WinMo), I also explicitly post DTM_ENABLESCRIPTING to the control. YMMV, but I HTH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM