WPF browser InvokeScript

ε祈祈猫儿з 提交于 2019-12-11 08:35:30

问题


Does anyone know why I am getting (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) when attempting to invoke a javascript function in a WPF application (.Net 4)?

The browser control is hosted inside an application and is being used with local html files, e.g:

C:\Users\XXXX\AppData\Roaming\XXXX\Books\XXXX_revision_1_1\html\1\med-9780198569244-chapter-4

This file has a javascript include - 'script/scripts.js'

Is it possible from C# to execute a javascript function using the InvokeScript method on the browser control when url is a local file?


回答1:


The simple answer was, I was calling it to early, it has to be after the page has loaded.

as stated in MSDN - http://msdn.microsoft.com/en-us/library/cc491132.aspx

'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.'



来源:https://stackoverflow.com/questions/6636420/wpf-browser-invokescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!