Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIURLFormatter

This article needs a technical review. How you can help.

This interface exposes methods to substitute variables in URL formats.
1.0
28
Introduced
Gecko 1.8
Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Variable names can contain 'A-Z' letters and '_' characters.

Mozilla applications linking to Mozilla websites are strongly encouraged to use URLs of the following format:

http[s]://%SERVICE%.mozilla.[com|org]/%LOCALE%/

Method overview

AString formatURL(in AString aFormat);
AString formatURLPref(in AString aPref);

Methods

formatURL()

Formats a string URL.

The set of known variables is predefined. If a variable is unknown, it is left unchanged and a non-fatal error is reported.

AString formatURL(
  in AString aFormat
);
Parameters
aFormat
Unformatted URL as a string.
Return value

The formatted URL.

formatURLPref()

Formats a string URL stored in a preference.

If the preference value cannot be retrieved, a fatal error is reported and the "about:blank" URL is returned.

AString formatURLPref(
  in AString aPref
);
Parameters
aPref
A string representing the name of the preference from which to fetch the URL to format.
Return value

The formatted URL returned by formatURL(), or "about:blank".

Document Tags and Contributors

 Contributors to this page: Sheppy, kscarfone, trevorh
 Last updated by: Sheppy,