dbuenzli / webbrowser

Open and reload URIs in browsers from OCaml
http://erratique.ch/software/webbrowser
ISC License
7 stars 2 forks source link

Extend browser support. #1

Open dbuenzli opened 7 years ago

dbuenzli commented 7 years ago

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.

apatil commented 6 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.?

dbuenzli commented 6 years ago

No. I want that to open/reload in the user's browser.

apatil commented 6 years ago

Got it.

Chris00 commented 5 years ago

I think this approach should be used.

dbuenzli commented 5 years ago

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.

Chris00 commented 5 years ago

Right. You have to send a local page with the script <iframe src="URI" mozbrowser remote>.

Chris00 commented 5 years ago

I suppose something similar is possible for other browsers.

Chris00 commented 5 years ago

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.

Chris00 commented 5 years ago

I forgot to point to the Firefox documentation.

Chris00 commented 5 years ago

I suppose JS could also reload the whole page using document.location.reload(true); — that should work on Chrome and Edge too.

dbuenzli commented 5 years ago

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.

Chris00 commented 5 years ago

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.

Chris00 commented 5 years ago

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...