Page 1 of 1
WebViewGadget: set URL
Posted: Sat Dec 23, 2023 11:21 am
by Marc56us
Hi,
How to set URL in new WebViewGadget ?
SetGadgetText set
text webpage
source.
I do this with success, But I think there's something simpler ?
Code: Select all
OpenWindow (0, 0, 0, 1000, 800,"", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebViewGadget(0, 10, 10, 980, 780)
*Buf = ReceiveHTTPMemory("https://www.purebasic.fr")
SetGadgetText(0, PeekS(*Buf, MemorySize(*Buf), #PB_UTF8 | #PB_ByteLength))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Did I miss something on the forum?

Re: WebViewGadget: set URL
Posted: Sat Dec 23, 2023 12:51 pm
by Fred
WebViewGadget() is meant to do web based UI, not to navigate on the web. You can use the WebGadget() for this (with the #PB_Web_Edge flag if you want to use the new WebView2 engine).
Re: WebViewGadget: set URL
Posted: Sat Dec 23, 2023 6:53 pm
by the.weavster
Fred wrote: Sat Dec 23, 2023 12:51 pm
WebViewGadget() is meant to do web based UI, not to navigate on the web.
Even so I'd want to be able to do:
Code: Select all
WebViewGadget(0, 10, 10, 980, 780)
SetGadgetText(0, "file:///index.html")
Re: WebViewGadget: set URL
Posted: Tue Dec 26, 2023 10:12 am
by pamen
In my humble opinion it is very important, not only simpler, to be able to load pages and at the same time execute JS, use callbacks for links/navigation all at the same time.
My example:
I have an email client, which must remove and add parts of html structure (done via text, not DOM), prevent scripts from running or run scripts, inject scripts and retrieve both HTML and text from a HTML DOM.
This is possible in multiplatform using javascript - works now fine with IE/GTK/Safari - although involves some extra code for each platform.
Additionally - HTML file can be opened form a file or downloaded via network, depends on situation.
In any case, at least setting a URL (local or remote) and JS callbacks (with numeric and string returns) in a component which displays HTML is a must for many uses.
I still don't get, why there are two components...
Re: WebViewGadget: set URL
Posted: Tue Dec 26, 2023 1:41 pm
by Fred
It's 2 different component because I don't want to be tied to a specific backend forever, for example we could use Sciter which is not a webbrowser. That way we have a specific web UI component which is more limited than a full blow web gadget(). That said I will add missing features if needed.
Re: WebViewGadget: set URL
Posted: Tue Dec 26, 2023 7:07 pm
by pamen
Understood, thank you Fred.
I used sciter - it is good as well and much leaner than a browser - better for new app design.
But full blown WebGadget main shortcoming was before exactly that, which can be done either by using VIEW component with full functionality and rendering or enhancements to WebGadget (more compatible with what people did in the last 10 years)
- no ability to access keys (CTRL-N will open a browser!), loading behavior (async, stop), intercept <a> clicks (Click on an email will fire email client, not possible to intercept)
- no ability to run JS with numeric and string returns