iOS Question OverrideUrl start direct when app start

appie21

Active Member
Licensed User
Longtime User
When i use this code and i launch my app this code will direct launch
What do I wrong

B4X:
Sub WebviewBreaking_OverrideUrl (Url As String) As Boolean
    WebView1.LoadUrl(Url)
    PnlWeb.BringToFront
    btnSluit.BringToFront
    PnlMain.Visible = False
    PnlWeb.Visible= True

Log(Url)
End Sub
 

appie21

Active Member
Licensed User
Longtime User
Oh this is what i do by android

Hello

I have 2 webviews
In one of the webviews there is loading a page with a hyperlink

Code:
<marquee behavior="scroll" direction="left">
<a href="https://www.b4x.com/android/forum/" target="_blank" style="color: yellow">Open site</a>
</a>

If I click the link the page will open in the same webview as where the hyperlink is.
 
Upvote 0

appie21

Active Member
Licensed User
Longtime User
I have also do that

B4X:
WebView1.LoadUrl(Url)
'    PnlWeb.BringToFront
'    btnSluit.BringToFront
    PnlMain.Visible = False
    PnlWeb.Visible= True
    Log(Url)
    Return True


I have
WebviewBreaking.LoadURL("http:")
in my startaplication

But if i launch my app it will immediately open
PnlMain.Visible = False
PnlWeb.Visible= True
and load WebviewBreaking.LoadURL("http://link.html") in the webview1 (who is on the Pnlweb)
and not the link from the code

<marquee behavior="scroll" direction="left">
<a href="https://www.b4x.com/android/forum/" target="_blank" style="color: yellow">Open site</a>
</a>
Also
WebviewBreaking is whithe

in B4a This work well

By ios I have add #ATSEnabled: False
 
Last edited:
Upvote 0

appie21

Active Member
Licensed User
Longtime User
B4X:
Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    Page1.RootPanel.LoadLayout("Main")
    NavControl.NavigationBarVisible = False

    NavControl.ToolBarVisible = False
    NavControl.ShowPage(Page1)
  
    New
  
End Sub




Private Sub New

  
    WebviewBreaking.Color = Colors.Red
    WebviewBreaking.LoadURL("http://xxx.com/tick.html")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)

End Sub

Private Sub Application_Background
  
End Sub

Sub BtnTerug_Click
  
    WebView1.GoBack
  
End Sub

Sub WebView1_PageFinished (Success As Boolean, Url As String)
  
  
End Sub


Sub WebviewBreaking_OverrideUrl (Url As String) As Boolean
    WebView1.LoadUrl(Url)
    PnlWeb.BringToFront
    btnSluit.BringToFront
    PnlMain.Visible = False
    PnlWeb.Visible= True
    Log(Url)
    Return True
  
End Sub

the idea is when they click the link webview1 will open with that link (now it open in WebviewBreaking it self)
 
Last edited by a moderator:
Upvote 0

appie21

Active Member
Licensed User
Longtime User
B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 7
    #ATSEnabled: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private WebView1 As WebView
    Private WebView2 As WebView
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    Page1.RootPanel.Color = Colors.White
    Page1.RootPanel.LoadLayout("Main")
    NavControl.NavigationBarVisible = False
    WebView1.LoadURL("http://ado.printhet3d.com/tick.html")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   
End Sub

Private Sub Application_Background
   
End Sub
Sub Webview1_OverrideUrl (Url As String) As Boolean
    WebView2.LoadUrl(Url)
   
    Log(Url)
    Return True
 
End Sub

I have made a new project

add webview 1 and 2 to main

If you load webview1 and click the link it will also open in webview1
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is what I see when I run your code:

SS-2018-08-06_12.10.38.png


Do you want to show the first page in WebView1?

Change your code to:
B4X:
Sub Webview1_OverrideUrl (Url As String) As Boolean
   Log(Url)
   If Url = "http://aaa.bbb.com/tick.html" Then Return False
   WebView2.LoadUrl(Url)
   Return True
End Sub
 
Last edited:
Upvote 0
Top