2012-10-27 47 views
2

Iam試圖在我的wpf應用程序中顯示html中的某種幫助頁面,並且我從我的資源管理器加載了html,它包含了多個我想從c#執行的javascript函數。不支持WPF Invokescript?

這是怎麼了應該做的事:

webBrowser1.InvokeScript("MyFunction"); 

這並不在所有的工作,我得到的錯誤代碼:

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

微軟對此並使用Google didn`t沒有幫助也做伎倆。

問題:如何在wpf瀏覽器中調用腳本?

回答

5

按照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. 

這傢伙here得到同樣的錯誤,原因是上面即努力已加載文檔之前調用規定的一個。