With a WPF WebBrowser, I'm trying to use a JavaScript method with the code:
WebBrowser.InvokeScript("eval", new object[] { if(typeof myMethod == 'function') { myMethod('param'); } });
My method :
function myMethod(param) {
alert(param);
}
If I put this method directly in my HTML file, it works. But if the method is in a separate file, it doesn't work. The JavaScript file is imported like so:
<script type='text/javascript' src='../script.js'></script>
And it works if I use methods of the script from my HTML page. The problem certainly is that InvokeScript tries to use a method inside my HTML and doesn't import the script.
How can I make this work?