FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Webview question
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Webview question
Posted: Tue Jul 04, 2023 06:39 AM

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.

Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Webview question
Posted: Tue Jul 04, 2023 11:42 AM
Code (fw): Select all Collapse
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.
Otto buenos días,

Si correcto comparto tu idea, creo que se pueden hacer muchas cosas de buena calidad visual con esta clase y sin servidor web :D . Lo que nos toca es empezar. jejejejeje
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Webview question
Posted: Tue Jul 04, 2023 12:25 PM

Leandro,

I'm already in the middle of it.

Best regards,

Otto

Posts: 92
Joined: Fri Nov 18, 2005 11:15 PM
Re: Webview question
Posted: Mon Jul 17, 2023 06:09 AM
Is it posible to insert a value to an input using oWebView:InjectJavascript()?
I tried with no success.

Code (fw): Select all Collapse
#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
Ralph del Castillo

Lima PERU

Fwh 24.07, xHb123_10193, MySQL 8.x, BCC 7.3
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Webview question
Posted: Mon Jul 17, 2023 07:25 AM
Dear Ralph,

After injecting the code you have to call it:

oWebView:Eval( "MyScript()" )

but first you need to implement such function in javascript:
Code (fw): Select all Collapse
function SetScript()

   local cHtml

   TEXT INTO cHtml
      <script>
      function MyScript() { 
      document.getElementById('num_ruc').value = '0123456789' ; }
      </script>
   ENDTEXT

return cHtml
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 92
Joined: Fri Nov 18, 2005 11:15 PM
Re: Webview question
Posted: Tue Jul 18, 2023 12:30 AM
I tested this sample successfully. May be this can help someone:
Code (fw): Select all Collapse
#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
Unfortunally, i can not make it work with this public page:
Code (fw): Select all Collapse
   oWebView:Navigate( "https://e-consulta.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm" )
  ....
The page contains elements with the same name.

Maybe, i think, the google-recaptcha it contains is avoiding javascript injection.
If someone can help, welcome!
Ralph del Castillo

Lima PERU

Fwh 24.07, xHb123_10193, MySQL 8.x, BCC 7.3
Posts: 253
Joined: Fri Feb 03, 2006 04:21 PM
Re: Webview question
Posted: Wed Jul 26, 2023 07:05 PM
Hello

I ask does it run PHP and JQuery without a server


not tested :D
Thanks,
Ari

FWH 2501 - Harbour 3.2.0 - Embarcadero 7.43 - MySQL
São Paulo - SP - Brasil
www.sisrev.com.br

Continue the discussion