iOS Question I Need help to open external link from webView

LusazDeveloper

Member
Licensed User
Thank you so much @mcqueccu It works but not at all for me. The url parameter captures the wrong page. I mean it should capture the link inside a webview (for example and <a href="something.html"></a>), instead the webview_OverrideUrl(Url As String) method is sending me to see the same page (out in safari) that is already set into the webview.

PD: I think that it is because I call the webview.loadUrl in the creation of the page. But I'm not pretty sure.
 
Upvote 0

LusazDeveloper

Member
Licensed User
This is the output of Log(Url)


I changed the ip for obvious reasons. But as I was explaining to @mcqueccu that is the link that should be loaded first in the webview. When the webview_OverrideUrl method executes it takes me to that direction out in Safari.

This is my code:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Menu")
    B4XPages.SetTitle(Me,"Menu")
    B4XPages.GetManager.LogEvents = True
    
    Agenda.Initialize("Agenda")
    Agenda.RootPanel.LoadLayout("AgendaPage")
    
    TabPages.Initialize   
    InitPages
    
    CargarAgenda
End Sub

Sub CargarAgenda   
    wvAgendaTab.LoadUrl("https://"&cualURL&"/sis/reportes/agenda_alumno_movil.php?ce="&codigo_centro_educativo&"&anio="&anio_lectivo&"&codigo="&codigo_alumno)
End Sub

Sub wvAgendaTab_OverrideUrl (Url As String) As Boolean   
    If Main.App.CanOpenURL(Url) Then Main.App.OpenURL(Url)
    Return True
End Sub
 
Upvote 0

LusazDeveloper

Member
Licensed User
Thanks a lot @Erel . I finally understood how it works and figured it out. Since the secondary page url starts with a diferent string, to prevent the first page from loading automatically I used:

The final code:
Sub wvAgendaTab_OverrideUrl (Url As String) As Boolean
    If Url.StartsWith("https://200") Then Return False
    Main.App.OpenURL(Url)       
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…