Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
639 views
in Technique[技术] by (71.8m points)

javascript - WPF Webbrowser invokeScript call external JS function

I have a function defined in a JS file.

Test.js

function fillData()
{
    alert("fill");
}

I have loaded the js file in html file like this.

Index.html

<html>
    <head>
        <title>TEST</title>
    </head>
    <script src="./PathToJs/Test.js" type="text/javascript"></script>  
 <body>
        <h1>Test Page</h1>
    </body>
</html>

I am calling this function from c# using webbrowser InvokeScript method.

webBrowser.InvokeScript("execScript", new Object[] { "fillData()", "JavaScript" });

But the method is not getting called. There is no alert box coming.

If the Javascript method is defined in the HTML itself then fillData() method is getting called.

Let me know how to call the external JS methods using WPF WebBrowser.InvokeScript method.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...