WPF Invokescript not supported?

3

Iam trying to display somekind of help page in html within my wpf application and Ive loaded the html from my resourcers and it contains multiple javascript functions that i want to execute from c#.

This is how it should be done:

webBrowser1.InvokeScript("MyFunction");

This does not work at all, I get the error code:

Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

Microsoft has no help regarding this and googling didn`t do the trick either.

Question: How do you invokescript in a wpf webbrowser?

c#
javascript
html
wpf
asked on Stack Overflow Oct 27, 2012 by makkesk8

1 Answer

6

As per 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.

This guy here getting the same error and the reason is the one stated above i.e. trying to invoke before the document has been loaded.

answered on Stack Overflow Oct 27, 2012 by Rohit Vats • edited Aug 17, 2018 by Hakan Fıstık

User contributions licensed under CC BY-SA 3.0