-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to inject script file with webviewcontroller.injectScriptFile() ? #154
Comments
With
To be able to load a file from the assets folder, see https://github.com/pichillilorenzo/flutter_inappwebview#load-a-file-inside-assets-folder Also, this plugin changed its name to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I tried to inject a js file with the
webviewcontroller.injectScriptFile(String urlFile)
of theflutter_inappbrowser
package in Flutter to an open InAppBrowser website. Actually my function in the js file that should be injected should automatically run when it is injected but it does not. There might be nothing wrong with my js file so it has to be the way on how I try to inject the file by the path or something.Here are the docs for the flutter_inappbrowser package: https://pub.dev/packages/flutter_inappbrowser
I tried the following: 1. I added my whole assets folder to be recognized by flutter in pubspec.yaml 2. My locale path to the js file is assets/js/example.js so I tried to give exactly this path to the parameter as a string. 3. I also tried to change my js file that there is a normal function and export it. And call this function with
webviewcontroller.injectScriptCode("functionFromJsFile()")
but error isfunctionFromJsFile() is not defined
EXAMPLE.JS:
CODE TO INJECT FILE INSIDE CLASS THAT EXTENDS INAPPBROWSER (The own class works as expected. Only the given line in onLoadStop does not.):
CODE FOR OPENING THE INAPPBROWSER:
I actually expect that when I then call the function to open the InAppBrowser the InAppBrowser opens the given website and bring me the alert. Everything works except the alert that comes from my given js file but js file is not even injected or something is wrong with the parameter
urlFile
which in my case is"assets/js/example.js"
The text was updated successfully, but these errors were encountered: