Open dbuenzli opened 7 years ago
@dbuenzli a slightly different approach in https://github.com/apatil/ocaml-webview should be cross-platform, at least in theory. Would that address the use case for which you wrote this library, or do you need a full-featured browser with forward and back buttons etc.?
No. I want that to open/reload in the user's browser.
Got it.
I think this approach should be used.
I think this approach should be used.
That doesn't allow you to reload arbitrary pages. You need to have the script on your page.
Right. You have to send a local page with the script <iframe src="
URI" mozbrowser remote>
.
I suppose something similar is possible for other browsers.
Generating the page wrapper also allows us to programmatically choose the port (since it must be in the web page) and also have a single websocket server for several URL (each page connecting to a different path on websocket server) that could automatically die if there are no connections for a given time from both applications and web pages.
I forgot to point to the Firefox documentation.
I suppose JS could also reload the whole page using document.location.reload(true);
— that should work on Chrome and Edge too.
I'm not sure exactly how it can achieve what it's doing now (which is to reload any tab you might have in your browser) also TBH that feels like killing a fly with an atomic bomb.
how it can achieve what it's doing now (which is to reload any tab
It can't reload any tab (because that requires browser scripting which does not seem to be readily available — short of writing a browser plugin) but it can reload tabs that were opened through the library, which is usually what one wants (it's not bad not to touch existing tabs).
that feels like killing a fly with an atomic bomb.
I agree and there may be other solutions but, in the absence of browser scripting, I guess they will involve JS talking to a small local server — maybe one can use a simpler one than a websocket.
Note that livereload uses the above technology to reload tabs when the underlying file is updated, so I'm not very confident there is a much simpler solution...
For now the full browser reload strategy is only supported on osx with chrome and safari. Help for extending support along the documentation is welcome.
xdg-open