defaultbrowser Command

Purpose

Launches the default web browser and optionally loads a specified URL.

Syntax

defaultbrowser [ URL [new-window, new-tab]]

Description

The defaultbrowser command runs the browser launch command that is specified in the DEFAULT_BROWSER environment variable.

If a URL is given as an argument, it loads that URL into the browser. For this to work properly, the browser command must accept a URL as an argument.

The optional new-window and new-tab arguments can be used if the browser that is being launched is the Mozilla web browser.

Both arguments must always be specified with a URL. This URL will then be opened in a new browser window or a new tab. If the browser is not the Mozilla web browser, these two arguments will be ignored.

The main purpose of the defaultbrowser command is to have applications use this command when they need to open a browser to display HTML documents or web-based applications.

This way, a system administrator only needs to change the DEFAULT_BROWSER environment variable when a new browser is installed and all applications will automatically begin using the new browser.

The DEFAULT_BROWSER environment variable should be set to the command that would launch the desired browser.

Include any arguments that must be included after the command to launch a specific URL address.

For example, if the command to launch a browser and open a specific URL is wonderbrowser -r URL, then the DEFAULT_BROWSER environment variable would be set to equal wonderbrowser -r.

If the DEFAULT_BROWSER environment variable is not defined, then the defaultbrowser command runs the Mozilla web browser if it is installed.

Examples

  1. To launch the designated default browser and have it open to it's default home page, type:
    defaultbrowser
  2. To launch the designated default browser and have it open to the URL http://machine/path/file.html, type:
    defaultbrowser http://machine/path/file.html
  3. To launch the designated default browser and have it open the URL http://machine/path/file.html where if the default browser is Netscape, then the page is displayed in a window called webpage, type:
    defaultbrowser http://machine/path/file.html webpage
  4. To launch the designated default browser and have it open the URL http://machine/path/file.html in a new browser window if the browser is the Mozilla web browser, type:
    defaultbrowser http://machine/path/file.html new-window
  5. To launch the designated default browser and have it open the URL http://machine/path/file.html in a new browser tab if the browser is the Mozilla web browser, type:
    defaultbrowser http://machine/path/file.html new-tab

Files

Item Description
/usr/bin/defaultbrowser The defaultbrowser command