Short Tag – Web Development Blog

Entries for September, 2011

Get and Set Preferences in XUL

Below are two funtions that will set and get boolean values in your firefox profile. These can be used in standalone XULRunner applications or in Firefox extensions.
Use them to save the settings of your application / extensions.

function setSettingValue(setting, value)
{
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");

prefs.setBoolPref(setting, value);
}

function getSettingValue(setting)
{
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");

return prefs.getBoolPref(setting);
}

For setting/getting int type preference use: getIntPref() and [...]

Cross-browser CSS code to disable selectable text

Maybe you created your own custom button from divs, or you just want to disable the ability to select text on an element (Usually is used for elements that act like buttons).

-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;

Use all these selectors on the element. This should work on all browsers.