Uniface User Forum

 View Only
  • 1.  open a website in the default browser via windows

    Posted 09-18-2024 10:11

    What is the best way to open a website from a unface desktop frm ... 

    My method is to create a batch file(1.bat) with the text start https:\mysite.com, and then activate an OS service which runs the created batch file.

    Im thinking there may be a better method.

    The problem I am having is that the website url has % in it, and the os service seems to be removing the percents in the case of opening a web site(not in the case of a dos command)...

    ex: https:\mysite.com?myvar=%1%

    So, my problem is how to open a website via a uniface desktop application that contains %'s



    ------------------------------
    Osman Shariff
    ------------------------------


  • 2.  RE: open a website in the default browser via windows

    Posted 09-19-2024 01:10

    Hi

    I don't know if it is the best method but I use OS signature to start the default browser (or specific one using the name of executable file: firefox.exe, chrome.exe, ...)

    activate "OS".command("cmd.exe /c start %%(VC_URL)")

    And, to avoid problems with data within the querystring, you have to use $encode function. Probably, you need to handle querystring as an associative list and replace its values by an urlencoded version. 

    putitem/id VA_querystring, "myvar", $encode("URL", "%1%")  ; VA_querystring = myvar=%251%25

    putitem/id VA_querystring, "other", $encode("URL", "%2%") 

    (Browser knows that %25 means "%")

    Finally, replace list separators (·;) by &. VC_querystring = $replace(VA_querystring, 1, "·;", "&", -1), and concatenate both separated by ?

     ;result should be https://mysite.com?myvar=%251%25&other=%252%25

    Regards



    ------------------------------
    Luis Vila
    luis.vila@uniface.es
    Spain
    ------------------------------



  • 3.  RE: open a website in the default browser via windows

    Posted 09-19-2024 03:22

    Thanks Luis, that was very insightful... and I got it working.

    In my case I already new the encoding so I did not need that bit, but it was very interesting.

    What worked for me was by calling the url direct in the activate as you did.

    I am not sure why, but writing to a .bat and then running the .bat in the activate lost the % characters.



    ------------------------------
    Osman Shariff
    ------------------------------



  • 4.  RE: open a website in the default browser via windows

    Posted 09-19-2024 07:18

    Hi,

    just spawn an explorer with the document you want.

    Works with html and office-Documents as well.

    spawn "explorer.exe %%"%%(V_URL)%%""



    ------------------------------
    Norbert Lauterbach
    Infraserv Gmbh & Co. Höchst Kg
    Frankfurt DE
    ------------------------------