welcome: please sign in
location: LoadSpec

The load-spec system is a uniform interface for extracting information such as an URL, a title, and much more, from a variety of different datatypes. Load-specs are used heavily in the browser object system, wherein the commands need to be able to operate not only on DOM nodes, but also html frames and even simple strings.


To use the load-spec system on a datum, cast the datum with the load_spec constructor, like this:

var spec = load_spec(thing);

You can now use load-spec accessors on the object to retrieve its properties without necessarily knowing its datatype. For example:

var uri = load_spec_uri(spec); // returns an nsIURI
var uri_string = load_spec_uri_string(spec); // returns a string
var title = load_spec_title(spec);

Occasionally, you may need to get the original datum out of a load spec.



Since a load-spec can be the container type for a dom node or a document, do not keep global references to load specs. Keeping references to dom nodes in memory prevents Mozilla from garbage-collecting the document that contains the node.

Conkeror.org: LoadSpec (last edited 2009-09-09 16:01:21 by retroj)