My application is compiled on the PhoneGap installed on my machine:
I use location.href = “https://www.papelaria.net” to go to my website! How do I return to the app to execute a function of my application like cordova.plugins.barcodeScanner.scan (codcerto, coderro)
How do I make my page call any of the functions below?
Example my code:
Sub Main
If location.search="" Then
location="https://www.papelaria.net"
Exit Sub
Else
buscar=Mid(location.search,2,Len(location.search))
comando=Split(buscar,"&")
If comando(0)="barra" Then
cordova.plugins.barcodeScanner.scan(codcerto, coderro)
End If
End If
End Sub
Function codcerto(result)
MsgBox result.text
End Function
Function coderro(result)
MsgBox result.text
End Function
Function busca()
MsgBox "Veio aqui"
End Function
Location.href should open an external window, you can’t really get back from that. Instead use the inappbrowser plugin and open a faux browser window (it doesn’t have nav bars etc)
Unable to get property 'open' of undefined or null reference.
line 8 column 5
I’ve done the installation on my phone gap
cordova plugin add cordova-plugin-inappbrowser
I don’t know what it can be anymore, can you help me?
Follow the code below:
Dim ref
Dim target
Dim options
Sub Main
target = "_blank"
options = "location=yes,hidden=yes,beforeload=yes"
ref = cordova.InAppBrowser.open("https://www.papelaria.net", target, options)
ref.addEventListener("callback",start(event))
' SetTimeout(fechar(),15000)
End Sub
Function start(event)
console.log("Passou aqui st " & event)
End Function
I finally managed to make it work perfectly!
Follow the code that works on mobile! Note: Does not work in the browser works only through the apk file!
Follow functional code! Thank you all!
Dim url
Dim siteretorno
Dim iabRef
Sub Main
url="https://www.papelaria.net/index.php"
document.addEventListener("deviceready", onDeviceReady, False)
End Sub
Function onDeviceReady()
iabRef = window.open(url, "_blank", "location=no,fullscreen=yes,zoom=no")
iabRef.addEventListener("loadstart", iabLoadStart)
iabRef.addEventListener("loadstop", iabLoadStop)
iabRef.addEventListener("loaderror", iabLoaderro)
iabRef.addEventListener("beforeload", beforeloadCallBack)
End Function
Function iabLoaderro(params)
If params.message="ERR_NAME_NOT_RESOLVED" Then
Alert1.value="Sem sinal de Internet:Endereço Não Resolvido:"
iabRef.close
ChangeForm(Form2)
End If
If params.message="ERR_ADDRESS_UNREACHABLE" Then
Alert1.value="Sem sinal de Internet: Endereço Inacessível!"
iabRef.close
ChangeForm(Form2)
End If
If params.message="ERR_CACHE_MISS" Then
Alert1.value="Perca de Cache!"
iabRef.close
ChangeForm(Form2)
Else
Alert1.value="Erro desconhecido!"
iabRef.close
ChangeForm(Form2)
End If
End Function
Function iabLoadStart(event)
Textarea1.text=Textarea1.text & vbCRLF & event.url;
console.log(event.type & "-" & event.url)
campo=Split(event.url,"?")
If campo(0)="https://www.papelaria.net/codigodebarra.php" Or campo(0)="https://www.papelaria.net/codigodebarra.php/" Then
comando=Split(campo(1),"&")
Textarea1.text=Textarea1.text & vbCRLF & "comando:" & comando(0)
If comando(0)="cmd=codigodebarra" Then
Textarea1.text=Textarea1.text & vbCRLF & "Entrou para executar"
retorno=Split(comando(1),"=")
siteretorno=retorno(1)
iabRef.close
cordova.plugins.barcodeScanner.scan(codcerto, coderro)
End If
End If
End Function
Function iabLoadStop(event)
Textarea1.text=Textarea1.text & vbCRLF & event.url
console.log(event.type & "-" & event.url)
campo=Split(event.url,"?")
If campo(0)="https://www.papelaria.net/codigodebarra.php" Or campo(0)="https://www.papelaria.net/codigodebarra.php/" Then
comando=Split(campo(1),"&")
If comando(0)="cmd=codigodebarra" Then
retorno=Split(comando(1),"=")
urlretorno=retorno(1)
iabRef.close
cordova.plugins.barcodeScanner.scan(codcerto, coderro)
End If
End If
End Function
Function codcerto(result)
url="https://www.papelaria.net/" & siteretorno & "?codigobarra=" result.text
document.addEventListener("deviceready", onDeviceReady, False)
End Function
Function coderro(result)
console.log(result.text)
End Function