mozdev.org

JSLib
Page Updated: July 20, 2004
Latest Version: 0.1.375
Debug | Install | File I/O | RDF | Network | Sound | Utils | XUL | Zip
Home | Mailing List | Install | Source Code | Downloads | Bugs | docs | clients

Prefs


File: utils/prefs.js

Status: Up to Date

Module Identifier: jslib_prefs

Fuction List

Example

To use the Prefs library:
// include the prefs library include (jslib_prefs); // constructor
var pref = new Prefs();

// enable dump output
const pref_str =
"browser.dom.window.dump.enabled";
if (!pref.getBool(
pref_str))
  pref.setBool(pref_str, true);

// set a proxy host
const pref_proxy_host = "network.proxy.http";
pref.setChar(pref_proxy_host,  "myserver");

// set proxy port
const pref_proxy_port = "network.proxy.http_port";
pref.setInt(
pref_proxy_port,  3128);

// get the pref host
var host = pref.getChar(
pref_proxy_host);

// get the pref port number
var port = pref.getInt(
pref_proxy_port);

// save the prefs to a file

// there are three ways to do this

// save to the default prefs file
pref.save();

// save to a specified file
pref.save("/tmp/my_prefs_1_file.js");

// save using an nsIFile object
include (jslib_file);
var f = new File (
"/tmp/my_prefs_2_file.js");
pref.save(f.nsIFile);



 




The jslib project can be contacted through the mailing list or the member list.
Copyright © 2000-2017. All rights reserved. Terms of Use & Privacy Policy.