in reply to Re^3: Reload Browser Tab on Windows
in thread Reload Browser Tab on Windows

yes it's static html.

> and that's why you want to reload the browser from the Perl script instead of from inside the HTML?

I don't get it, any JS or meta-tag solution would indiscriminately work from a static file too.

> (And even if that's the case, why not just whip up a quick server that serves the HTML on a local address? That way you could solve this using JS / Websockets / etc.)

I like automating my desktop beyond my IDE, it's purely for reducing turnaround time

And installing Mojo and getting acquainted with websockets would stop my current project.

(That's basically the drama of my many projects, instead of "getting done" I'm hopping around trying to "get it right")

Anyway I have a powershell solution now, which fits into one line. No need to install anything else. :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: Reload Browser Tab on Windows
by haukex (Archbishop) on Dec 22, 2020 at 08:39 UTC
    I don't get it, any JS or meta-tag solution would indiscriminately work from a static file too.

    Well yes, they would work insofar as they can reload the page, but in the root node you said "reload the page after running my script", so I thought this timing was important: my guess was that your script would be generating the static HTML file and you want to reload the browser with that newly generated HTML. This is IMHO much simpler (and probably more importantly, cross-platform and cross-browser portable) to do with a live connection to an HTTP server...

    And installing Mojo and getting acquainted with websockets would stop my current project.

    It's not that difficult ;-) In the very basic form, you just need some HTTP server and the HTML page can poll the server. The EventSource API and WebSockets are just advanced forms. If you were to give more specifics, like what this script is generating, how complex the script is (i.e. if it could be integrated into a webserver easily or it should stay standalone), how long the generation takes (i.e. whether it can be done in a few ms on the fly or it takes a minute), how often it gets run, and so on, I could make a more specific suggestion.

      There basically is a premade Mojolicious solution with Mojolicious::Plugin::AutoReload, which does the automatic reloading already:

      use Mojolicious::Lite; plugin AutoReload => {}; get '/' => 'index'; app->start; __DATA__ @@ index.html.ep Hello world!

      To use external files, you have to add an after_static hook, which is mainly what my App::Mojo::AssetReloader does, but LanX already knows about these :)