iOS Question [RESOLVED] Click webview to B4I

Duque

Active Member
Licensed User
Longtime User
After 3 days of searching for solutions and trying almost everything, I don't want to give up on b4i.
Context:
I have a table in a Webview, the user can click on a cell and see information (this is already done for b4a and b4j).

[CODE lang="javascript" title="For b4a I use this in webview, WebViewExtras"]<script>
function pulsa_cell(myDato){
B4A.CallSub('pulsa_cell',true,myDato);
}
</script>[/CODE]

[CODE lang="javascript" title="For b4j I use this in webview, setBridge"]
<script>
function pulsa_cell(myDato){
b4j.link2(myDato);
}
</script>
[/CODE]

After 3 days of searching the forum, I found some links, where they say they solve it for b4i but they don't leave any example

I understood that iOS does things differently and I must activate the OverrideUrl event.
[CODE lang="javascript" title="For B4i I use this in webview, IT DOES NOT WORK"]
<script>
function pulsa_cell(myDato){
window.location.href;
}
</script>
[/CODE]
When I click on the web view cell it does nothing
[CODE lang="html" title="HTML button"]<td>
<button onclick="pulsa_cell('string_json_b64')">Web to B4i</button>
</td> [/CODE]

Please help me !
 
After 3 days of searching for solutions and trying almost everything, I don't want to give up on b4i.
Context:
I have a table in a Webview, the user can click on a cell and see information (this is already done for b4a and b4j).

[CODE lang="javascript" title="For b4a I use this in webview, WebViewExtras"]<script>
function pulsa_cell(myDato){
B4A.CallSub('pulsa_cell',true,myDato);
}
</script>[/CODE]

[CODE lang="javascript" title="For b4j I use this in webview, setBridge"]
<script>
function pulsa_cell(myDato){
b4j.link2(myDato);
}
</script>
[/CODE]

After 3 days of searching the forum, I found some links, where they say they solve it for b4i but they don't leave any example

I understood that iOS does things differently and I must activate the OverrideUrl event.
[CODE lang="javascript" title="For B4i I use this in webview, IT DOES NOT WORK"]
<script>
function pulsa_cell(myDato){
window.location.href;
}
</script>
[/CODE]
When I click on the web view cell it does nothing
[CODE lang="html" title="HTML button"]<td>
<button onclick="pulsa_cell('string_json_b64')">Web to B4i</button>
</td> [/CODE]

Please help me !
window.location.href = window.location + "&string_json_b64";


you can use something like that in your webpage and handle in B4I something like
Private Sub WebView1_OverrideUrl (Url As String)
 
Upvote 0
If you have this same problem, check out my solution.
[CODE lang="javascript" title="In JavaScript"]<script>
function pulsa_cell(myDato){
window.location.href = window.location + "INI_B64" + myDato;
}
</script>[/CODE]

This could be more elegant, but I was 3 days late so I did it quickly...
[CODE lang="b4x" title="In B4i"]Private Sub tabla_OverrideUrl (Url As String) As Boolean
Dim const IDentificador As String = "INI_B64"
If (Url.Contains(IDentificador)) Then
Dim const recortar As Int = Url.IndexOf(IDentificador) + IDentificador.Length
dim const myDato as string = Url.SubString2(recortar, Url.Length)
log(myDato) '<---Capture the parameter I want from the web view
End If
Return True
End Sub[/CODE]
 
Last edited:
Upvote 0
Back
Top