iOS Question How to load js file in WKWEBVIEW

watesoft

Active Member
Licensed User
Longtime User
I use wkwebview to load one js file(not js string) and show webp file,but it doesn't work.
I think the problem is in the loading way of the js file.

B4X:
Sub WKWebView_PageFinished (Success As Boolean, Url As String)
    Dim jss As String
    jss=$"<script type="text/javascript" src="${WebViewAssetFile("webpjs.js")}"></script>"$

    WKWebView.EvaluateJavaScript("", jss)
End Sub

B4X:
Sub WebViewAssetFile (FileName As String) As String

    Return $"file://${File.Combine(File.DirDocuments, FileName)}"$

End Sub

About webpjs.js file,you can visit https://webpjs.appspot.com/,I rename webpjs-0.0.2.min.js to webpjs.js.
 
Last edited:

watesoft

Active Member
Licensed User
Longtime User

Erel,thank you.
I know that WKWEBVIEW does not currently support webp format images. Some people have used js to implement this function. I have not learned javascript. Although I tried to use this js plugin, I have not succeeded. Since there is not much time to solve this problem, I temporarily give up.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…