Closed ttytm closed 10 months ago
Thats because webui.js
is not loaded there. When changing the page the websocket connection drops, on the new page if there is no <script src="/webui.js">
then it wont reconnect. WebUI cant control the browser and cannot close it, at this point webui_wait()
returns and browser window remains open.
Tho with the second.html
in the mentioned example, webui.js
is included on the page.
https://github.com/webui-dev/webui/blob/main/examples/C/serve_a_folder/second.html
One solution would be to state it as a requirement that page navigation inside the webui application requires a programmatic approach from the backend and adjust the example.
Right, in simple link
exit doesnt work.
I think this has something to do with bindings
. Both buttons
call webui_show()
which I think re-binds to the DOM elements. If direct link is clicked new page is opened directly by the browser and no re-binding by WebUI is done. Events such as clicks are still captured, but #Exit
element is not binded.
Found the problem. Bindings are ok, that would be weird coz they are in webui.js..
The problem is that the window cant be closed by script if that script didnt open that window. Security measures. And in this case the script (webui.js
) didnt open the window, you did by clicking the link.
Its a bug in the example, not WebUI.
One solution would be to state it as a requirement that page navigation inside the webui application requires a programmatic approach from the backend and adjust the example.
Agree. I always had in mind WebUI is a solution that "loads the page once", and all things must be done dynamically.
Found the problem. Bindings are ok, that would be weird coz they are in webui.js..
The problem is that the window cant be closed by script if that script didnt open that window. Security measures. And in this case the script (
webui.js
) didnt open the window, you did by clicking the link.
Good find!
WebUI cant control the browser and cannot close it, at this point webui_wait() returns and browser window remains open.
Hmm, thinking about it, maybe it's possible to control it. WebUI already provides an api to get the process ids, so ending the process on webui_exit
should theoretically be possible.
Thank you for the report. Fixing this issue led to the creation of a new API.
Now, when using all-events webui_bind(MyWindow, "", events)
WebUI then will block all href
requests, then the user will receive the event and decide to call webui_navigate()
or not.
If no all-events is used, then everything will work as normal.
@hassandraga can you check if this new feature, catching all hrefs, works on Firefox? In my case it doesnt, on Chrome & Edge it works.
I did not test it in Firefox. I will double-check.
webui_exit
won't work after changing a page through a link, e.g. in the serve a folder example. The window will stay open. It works when programatically changing the page via the backend.