Login  Register

Re: open URL in non-default browser?

Posted by dscho on Oct 09, 2009; 7:35am
URL: http://imagej.273.s1.nabble.com/open-URL-in-non-default-browser-tp3690885p3690886.html

Hi,

On Fri, 9 Oct 2009, b holi wrote:

> run("URL...", urlString) will open the url in the default browser.
>
> From ImageJ, can an alternate browser be targeted or selected to open
> instead?

Sure, as long as you can be certain that the alternate browser you have in
mind is installed, you can always use java.lang.Runtime's exec() methods.

It is prone to failure, though, as

- the browser might not be installed, and

- it might get tricky to find out where the browser's executable is
  located (think of Microsoft Windows)

> I have developed several browser javascript applications to be run on
> the localhost as ImageJ 'helper apps' but I want to avoid having ImageJ
> open them in MS Internet Explorer.  From the applications I can detect
> which browser is launched and close the window if it is MSIE (to avoid
> presenting the user with fatal javascript errors), but I'm hoping to
> avoid directing users to open the HTML files manually in a different
> browser.  These are large applications developed in Gecko browsers and I
> am not eager to accept the project of taking them to Internet Explorer.

I fear you will have to do the same as generations of developers before
you: grudgingly add work-arounds for Microsoft's Internet Explorer.  A
large part of the general user base still uses this browser (most as the
only browser, if I remember correctly), after all.

Ciao,
Dscho