Reputation: 214
I am calling a webview, lets call it main index.html
that has a JS file with displayAlert()
method.
It has another index.html
as its innerHTML
(this is inside a test folder).
Whenever i call await webViewController.runJavascript("displayAlert()");
, it gives Uncaught ReferenceError : displayAlert is not defined, source:file"///PATH_TO_ANDROID_STORAGE/test/index.html
Somehow the callback is being forwarded to innerHTML
instead of main index.html
processing it.
This happens only on android and not on iOS.
I am using "https://pub.dev/packages/webview_flutter"
Upvotes: 0
Views: 262
Reputation: 694
If I'm reading correctly, you are importing index.html from assets that has a <Script>
tag with a link to another asset file.
As of December 2022 This does not work in Flutter WebView.
You need to embed your JS file code into the actual index.html or link to a public resource on the web, i.e.
<script src="https://example.tld/my.js"></script>
Upvotes: 0