开发者

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开发者_JS百科 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜