iOS Question Webview to Objective C

carloz

Member
Licensed User
Longtime User
Hello All,

I have been using b4a for a while now and am a great fan of using webviewxtras, I belive that webviewxtras is not available in b4i.

What i am trying to achive here is( I hope i am explaining this correctly ..)
Clicking on "Link1" in webview should open a pdf from mainbundle
Clicking on "Link2" in webview should open a mp4 from mainbundle

I can use this library to open pdfs/mp4 in external app
https://www.b4x.com/android/forum/threads/open-local-files-with-external-apps.51941/#post-328629

How do i go about calling app procedure from webview? any suggestions?

regards
carloz
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,
you can use the OverrideUrl event:
B4X:
   WebView1.LoadHtml($"
   <a href="OpenPDF">Link1</a>
   <br>
   <br>
   <a href="OpenVideo">Link2</a>
   "$)

Sub WebView1_OverrideUrl (Url As String) As Boolean
    Dim Tag As String = Url.SubString2(Url.LastIndexOf("/") +1,Url.Length)
    Select Tag
        Case "OpenPDF"
            Log("PDF")
            Return False
        Case "OpenVideo"
            Log("Video")
            Return False
    End Select
End Sub
 
Upvote 0
Top