简体   繁体   中英

Throwing error on JS InvokeScript with WebBrowser control

"Object doesn't support property or method fireEvent."

I get this error when I try to invoke a script on a WebBrowser control with the InvokeScript(); method. I'm trying to simulate a click on a link element, and instead I get a MessageBox with this error.

Make sure that the document is fully loaded.

From msdn:

InvokeScript(String) should not be called before the document that implements it has finished loading. You can detect when a document has finished loading by handling the LoadCompleted event.

http://msdn.microsoft.com/en-us/library/cc491132.aspx

Based upon the information you provided, we can only make guesses about what's wrong. However, if you're calling a JavaScript function with InvokeScript , you can easily figure out the problem yourself: use script debugger and set a breakpoint in your JavaScript code. Here's how to do that (originally for AOL Browser, but it's also a WebBrowser hosting app, so the same technique should work for your app as well).

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