0

My Flutter app loads a webpage using the webview_flutter package. I have successfully passed info from the webpage to Flutter, using javascriptChannels. I have also successfully run built-in Javascript, from Flutter to the webpage. (Like launching an alert!)

But! How can I execute a Javascript function on the webpagem from Flutter. (Not merely run a built-in Javascript methods?)

Say my webpage has a function called helloWord(), what is the dart code to trigger that function from Flutter?

1 Answer 1

0

DOH! I needed to add the "window" object to the front of the function...

So this code did the trick:

_webViewController.runJavascript('window.helloWorld()');   

I am posting in case others have this issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.