I think with webview2, it is now possible to develop a single user interface for both the web and the desktop . Simply by replacing the function 'SendToFWH' with an AJAX call, one can change the access: either web browser or webview2.
#include "FiveWin.ch"
static oWebView
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Consulta de Comprobantes"
oWnd:Center()
oWebView = TWebView():New(, oWnd:hWnd )
oWebView:Navigate( "https://e-consulta.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm" )
oWebView:InjectJavascript( SetScript() )
oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
ACTIVATE WINDOW oWnd CENTER ;
ON RESIZE If( nWidth != nil, oWebView:SetSize( nWidth, nHeight ), oWebView:SetSize( 1000, 700 ) )
oWebView:Destroy()
return nil
function SetScript()
local cHtml
TEXT INTO cHtml
<script>
document.getElementById('num_ruc').value = '0123456789' ;
</script>
ENDTEXT
return cHtml
function SetScript()
local cHtml
TEXT INTO cHtml
<script>
function MyScript() {
document.getElementById('num_ruc').value = '0123456789' ; }
</script>
ENDTEXT
return cHtml
#include "FiveWin.ch"
static oWebView
function Main()
local oWnd, cFile
DEFINE WINDOW oWnd TITLE "Consulta de Comprobantes" MENU BuildMenu()
oWnd:Center()
oWebView = TWebView():New(1, oWnd:hWnd )
oWebView:Navigate( "https://myefacts.com/test/")
oWebView:SetSize( 1000, 700 )
oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
oWebView:Bind( "SendToFWH" )
oWebView:bOnBind = { | cJson, cCalls | cFile:="c:\temp\respuesta.json" , StrFile( cJson, cFile), alert(cFile) }
Sleep( 400 )
oWebView:InjectJavascript( SetScript() )
oWebView:Eval( "MyScript()" )
ACTIVATE WINDOW oWnd CENTER ;
oWebView:Destroy()
return nil
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Source." ACTION oWebView:Eval( "SendToFWH( document.body.outerHTML )" )
MENUITEM "Load ." ACTION (oWebView:Eval( "MyScript()" ), oWebView:Eval( "alert( 'asignado '+document.getElementById('num_ruc').value )" ) )
MENUITEM "About ." ACTION MsgAbout()
ENDMENU
return oMenu
//---------------------
function SetScript()
local cHtml
TEXT INTO cHtml
function MyScript() {
document.getElementById("num_ruc").value = '20123456781' ;
}
ENDTEXT
return cHtml
oWebView:Navigate( "https://e-consulta.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm" )
....
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 78 guests