Open a URL in a new browser tab?

Sounds like the sort of thing that must already exist, but I can’t
find it…

Is there a standard cross-platform way in Ruby to drive the user’s
default web browser to open a URL in a new window/tab? Because if
not, I have code samples for all major platforms and will create a
gem.

I have this notion of using ruby2exe to turn a Camping app into an
single executable that opens in the browser, without having anything
pre-installed on the target machine… and that needs the open-URL
feature.

Clifford H…

Can it really be that I’m the only person that’s ever wanted this?

Mechanize and the like make it easy to act as a web client, and
various tools act as a server, but the case of a web app that
should run and display on a local system can’t really be that
unique, can it?

Ok, I guess up up for a new gem… sometime.

Clifford H…

Clifford H. wrote:

Is there a standard cross-platform way in Ruby to drive the user’s
default web browser to open a URL in a new window/tab? Because if
not, I have code samples for all major platforms and will create a
gem.

Does “all major platforms” include Linux/Unix? If so, how do you find
out what
the user’s default browser is there?

Code for each browser is most appropriate, but some browsers lie or
can lie when doing browser sniffing.
So this is probably (currently) unreliable.
New Tab or New Window is, like CSS often up to the user ultimately,
so probably better if you don’t try to control it.
Better to aim for reliably predictable functionality

Sebastian H. wrote:

Does “all major platforms” include Linux/Unix? If so, how do you find out what
the user’s default browser is there?

The browser will often be already running, and I expect that most X11
browsers will have adopted the Netscape procedure (using X properties,
I have code for that from years ago) to be told which URL to open. I
don’t think it distinguishes windows from tabs, but that’s not really
for the caller to control anyhow.

If the X display variable isn’t set, or the relevant properties aren’t
on the display, then you need to either fail or start a browser. A
list of several of the most popular would be an acceptable way to
start, and a preferred-browser environment variable would allow
customization after that.

Clifford H…