setCharPref or setBoolPref does not work properly.

VERIFIED WORKSFORME

Status

()

Core
Embedding: APIs
VERIFIED WORKSFORME
17 years ago
17 years ago

People

(Reporter: dsirnapalli, Assigned: Alec Flett)

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

17 years ago
I used the following piece of code.

var nsIPrefBranchObj = nsIPrefServiceObj.getDefaultBranch(null);
alert(nsIPrefBranchObj.getCharPref("browser.startup.homepage"));
nsIPrefBranchObj.setCharPref("browser.startup.homepage", "http://www.goto.com");
nsIPrefServiceObj.savePrefFile(null);
alert(nsIPrefBranchObj.getCharPref("browser.startup.homepage"));

The second alert shows the right value.It shows "http://www.goto.com", but when 
i open prefs.js, it still contains the old value.That means it's picking up the 
value from memory.When i close mozilla browser pref.js still contains the old 
value. When i run the above code again the first alert picks up the homepage 
from all.js("chrome://navigator-region/locale/region.properties") even though 
pref.js contains "www.mozilla.org".

Comment 1

17 years ago
I think if you do
var nsIPrefBranchObj = nsIPrefServiceObj.getBranch(null);

This code will do what you expect it to...

(Assignee)

Comment 2

17 years ago
yes, they work, or the browser wouldn't save preferences!
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 3

17 years ago
when i use..
var nsIPrefBranchObj = nsIPrefServiceObj.getBranch(null);
it works.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.