Forum: Ruby Open a URL in a new browser tab?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
163755a5d3a5c57bd79c4f41bdda7a22?d=identicon&s=25 Clifford Heath (Guest)
on 2007-03-02 23:25
(Received via mailing list)
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 Heath.
163755a5d3a5c57bd79c4f41bdda7a22?d=identicon&s=25 Clifford Heath (Guest)
on 2007-03-04 07:05
(Received via mailing list)
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 Heath.
7a561ec0875fcbbe3066ea8fe288ec77?d=identicon&s=25 Sebastian Hungerecker (Guest)
on 2007-03-04 10:09
(Received via mailing list)
Clifford Heath 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?
1c0cd550766a3ee3e4a9c495926e4603?d=identicon&s=25 John Joyce (Guest)
on 2007-03-04 11:38
(Received via mailing list)
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
163755a5d3a5c57bd79c4f41bdda7a22?d=identicon&s=25 Clifford Heath (Guest)
on 2007-03-04 12:10
(Received via mailing list)
Sebastian Hungerecker 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 Heath.
This topic is locked and can not be replied to.