X
點擊此處開啟此網站的行動版。

技術支援討論區

Firefox default configuration

已張貼

Hello

I want to configure firefox 14.0.1 with default settings for all my users using a file mozilla.cfg But the command defaultPref () is not valid. I use pref () but then the user can not change the parameters

With Thunderbird 14.0, I have no problem, the command defautPref () can be used

Why?

Thank you

Hello I want to configure firefox 14.0.1 with default settings for all my users using a file mozilla.cfg But the command defaultPref () is not valid. I use pref () but then the user can not change the parameters With Thunderbird 14.0, I have no problem, the command defautPref () can be used Why? Thank you

由 sxpi 於 修改

被選擇的解決方法

Yes, the problem appears to have been resolved in 16 and later. It's not clear to me whether there was any problem in 15 or not but it doesn't really matter now.

從原來的回覆中察看解決方案 0
cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

Are there any errors in the error console?

Does it work if you leave out the space: defaultPref()?

You can use these functions in mozilla.cfg:

defaultPref();  // set new default value
pref();         // set pref, but allow changes in current session
lockPref();     // lock pref, disallow changes

See also:

Are there any errors in the error console? Does it work if you leave out the space: defaultPref()? You can use these functions in mozilla.cfg: defaultPref(); // set new default value pref(); // set pref, but allow changes in current session lockPref(); // lock pref, disallow changes See also: *http://kb.mozillazine.org/Locking_preferences

提出問題者

Excuse me but I made a typo in my post
It should be defautPref() and pref()

For exemple:

When I create a mozilla.cfg with:

// Mozilla Preferences
defaultPref("browser.startup.page", 1);
defaultPref("browser.startup.homepage", "http://www.xyz.com/");

Firefox doesn't take these preferences

but when I write:

// Mozilla Preferences
pref("browser.startup.page", 1);
pref("browser.startup.homepage", "http://www.xyz.com/");

Firefox takes these preferences but the user can't change the startup homepage afterwards

Excuse me but I made a typo in my post <br> It should be defautPref() and pref() For exemple: When I create a mozilla.cfg with: // Mozilla Preferences <br> defaultPref("browser.startup.page", 1); <br> defaultPref("browser.startup.homepage", "http://www.xyz.com/"); Firefox doesn't take these preferences but when I write: // Mozilla Preferences <br> pref("browser.startup.page", 1); <br> pref("browser.startup.homepage", "http://www.xyz.com/"); Firefox takes these preferences but the user can't change the startup homepage afterwards

由 sxpi 於 修改

cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

Works for me.

Note that the default only works if the pref hasn't been user set (i.e. isn't bold on the about:config page).
In that case you need to reset the pref via the right-click context menu to the default to give it the new value or remove the corresponding lines from the prefs.js file and a possible user.js file.

Works for me. Note that the default only works if the pref hasn't been user set (i.e. isn't bold on the about:config page).<br /> In that case you need to reset the pref via the right-click context menu to the default to give it the new value or remove the corresponding lines from the prefs.js file and a possible user.js file.

提出問題者

I have the problem with all new profile defined on my windows 7
By default, the new profile has no "mozilla" folder in c:\users\username\appdata\roaming and c:\users\username\appdata\local

I have the same problem with Ubuntu 12.04 LTS and firefox 14.0.1

i see https://bugzilla.mozilla.org/show_bug.cgi?id=451161 but it marked Resolve Fixed

Perhaps i have an error in the content of mozilla.cfg but i don't see where

I have the problem with all new profile defined on my windows 7 <br> By default, the new profile has no "mozilla" folder in c:\users\username\appdata\roaming and c:\users\username\appdata\local I have the same problem with Ubuntu 12.04 LTS and firefox 14.0.1 i see https://bugzilla.mozilla.org/show_bug.cgi?id=451161 but it marked Resolve Fixed Perhaps i have an error in the content of mozilla.cfg but i don't see where
cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

Are you sure that the prefs.js file doesn't yet have one or more of those lines?

Like, I posted above as soon as a pref is user set then defaultPref() doesn't have any effect. It only define the default to use if the pref doesn't exist or if you reset the pref or its corresponding setting to the default.

You can use this button to go to the Firefox profile folder if you can't locate it:

  • Help > Troubleshooting Information > Profile Directory: Open Containing Folder
Are you sure that the prefs.js file doesn't yet have one or more of those lines? Like, I posted above as soon as a pref is user set then defaultPref() doesn't have any effect. It only define the default to use if the pref doesn't exist or if you reset the pref or its corresponding setting to the default. You can use this button to go to the Firefox profile folder if you can't locate it: *Help > Troubleshooting Information > Profile Directory: Open Containing Folder *https://support.mozilla.org/kb/Profiles

提出問題者

new windows, new username, new profile

When you start firefox for the first time, it creates a mozilla folder with parameters that you are defined in c:\Program files (x86)\Mozilla firefox\mozilla.cfg

Reminder, i don't have the problem with thunderbird only with firefox

new windows, new username, new profile When you start firefox for the first time, it creates a mozilla folder with parameters that you are defined in c:\Program files (x86)\Mozilla firefox\mozilla.cfg Reminder, i don't have the problem with thunderbird only with firefox
harryjohnston 1 個解決方法 11 個答案

I have the same problem. The defaultPref command is being processed (because I get error messages if, for example, I try to set a boolean preference with a string value) but the changes do not take effect.

The about:config page shows the preferences with status "default" and the original default value, not the default value I've set.

I have the same problem. The defaultPref command is being processed (because I get error messages if, for example, I try to set a boolean preference with a string value) but the changes do not take effect. The about:config page shows the preferences with status "default" and the original default value, not the default value I've set.
cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

You have to make sure to initialize prefs with the correct data type to avoid problems.

Be aware the mozilla.cfg is run as a normal JavaScript file contrary to prefs.js and user.js that are parsed, so you can add test code or a try{}catch(e){} to trap errors if exceptions are thrown.

You have to make sure to initialize prefs with the correct data type to avoid problems. Be aware the mozilla.cfg is run as a normal JavaScript file contrary to prefs.js and user.js that are parsed, so you can add test code or a try{}catch(e){} to trap errors if exceptions are thrown.
harryjohnston 1 個解決方法 11 個答案

I am initializing prefs with the correct data type, and no exception is being thrown. It just doesn't *do* anything.

I can reproduce this with a very simple mozilla.cfg:

//

defaultPref("browser.startup.page", 0);

(The extra blank line isn't in my file, I just don't know how to make it appear properly here.)

I am initializing prefs with the correct data type, and no exception is being thrown. It just doesn't *do* anything. I can reproduce this with a very simple mozilla.cfg: // defaultPref("browser.startup.page", 0); (The extra blank line isn't in my file, I just don't know how to make it appear properly here.)

由 harryjohnston 於 修改

cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

Did you make sure that the prefs.js and possible user.js files do not have a line with that pref?

  • user_pref("browser.startup.page", #);

Did you test this with creating a new profile?

Did you make sure that the prefs.js and possible user.js files do not have a line with that pref? *user_pref("browser.startup.page", #); Did you test this with creating a new profile?
harryjohnston 1 個解決方法 11 個答案

Yes, I've tried with a new profile. There's no such entry in prefs.js and no user.js file at all.

Yes, I've tried with a new profile. There's no such entry in prefs.js and no user.js file at all.
harryjohnston 1 個解決方法 11 個答案

Using process monitor and by sticking some debugging code into prefcall.js it looks as if the problem is that the standard default preferences files (greprefs.js, firefox.js, etc.) are reloaded *after* mozilla.cfg is processed, overwriting any unlocked preferences set in mozilla.cfg.

Using process monitor and by sticking some debugging code into prefcall.js it looks as if the problem is that the standard default preferences files (greprefs.js, firefox.js, etc.) are reloaded *after* mozilla.cfg is processed, overwriting any unlocked preferences set in mozilla.cfg.
harryjohnston 1 個解決方法 11 個答案

Workaround: instead of using mozilla.cfg, put your custom default settings in the local-settings.js preferences file. This will no longer work if you put the file in defaults\pref, but will work if you create a new folder defaults\preferences and put it there.

Sample local-settings.js file:

pref("browser.startup.page", 0);

An example of setting the home page:

pref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.scms.waikato.ac.nz/labs/windows.html");

Workaround: instead of using mozilla.cfg, put your custom default settings in the local-settings.js preferences file. This will no longer work if you put the file in defaults\pref, but will work if you create a new folder defaults\preferences and put it there. Sample local-settings.js file: pref("browser.startup.page", 0); An example of setting the home page: pref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.scms.waikato.ac.nz/labs/windows.html");
harryjohnston 1 個解決方法 11 個答案

Submitted as bug # 786875

Submitted as bug # 786875
cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

Works for me on Linux.
I use pref() to set the home page and the new tab page and changed them to defaultPref() for testing and both versions work for me.

//

//pref("browser.startup.homepage", "about:about");
//pref("browser.newtab.url", "about:blank");

defaultPref("browser.startup.homepage", "about:about");
defaultPref("browser.newtab.url", "about:blank");

data:text/plain;charset=utf-8;base64,Ly8KCi8vcHJlZigiYnJvd3Nlci5zdGFydHVwLmhvbWVwYWdlIiwgImFib3V0OmFib3V0Iik7Ci8vcHJlZigiYnJvd3Nlci5uZXd0YWIudXJsIiwgImFib3V0OmJsYW5rIik7CgpkZWZhdWx0UHJlZigiYnJvd3Nlci5zdGFydHVwLmhvbWVwYWdlIiwgImFib3V0OmFib3V0Iik7CmRlZmF1bHRQcmVmKCJicm93c2VyLm5ld3RhYi51cmwiLCAiYWJvdXQ6YmxhbmsiKTsK
Works for me on Linux.<br /> I use pref() to set the home page and the new tab page and changed them to defaultPref() for testing and both versions work for me. <pre><nowiki>// //pref("browser.startup.homepage", "about:about"); //pref("browser.newtab.url", "about:blank"); defaultPref("browser.startup.homepage", "about:about"); defaultPref("browser.newtab.url", "about:blank"); </nowiki></pre> ---- <pre><nowiki>data:text/plain;charset=utf-8;base64,Ly8KCi8vcHJlZigiYnJvd3Nlci5zdGFydHVwLmhvbWVwYWdlIiwgImFib3V0OmFib3V0Iik7Ci8vcHJlZigiYnJvd3Nlci5uZXd0YWIudXJsIiwgImFib3V0OmJsYW5rIik7CgpkZWZhdWx0UHJlZigiYnJvd3Nlci5zdGFydHVwLmhvbWVwYWdlIiwgImFib3V0OmFib3V0Iik7CmRlZmF1bHRQcmVmKCJicm93c2VyLm5ld3RhYi51cmwiLCAiYWJvdXQ6YmxhbmsiKTsK</nowiki></pre>

由 cor-el 於 修改

harryjohnston 1 個解決方法 11 個答案

Does it still work for a new profile? Might using pref() rather than defaultPref() have tattooed your profile?

(I've just tried this myself, and indeed, once pref() has been used the setting sticks in the user profile.)

Does it still work for a new profile? Might using pref() rather than defaultPref() have tattooed your profile? (I've just tried this myself, and indeed, once pref() has been used the setting sticks in the user profile.)

由 harryjohnston 於 修改

cor-el
  • Top 10 Contributor
  • Moderator
17472 個解決方法 157915 個答案

有幫助的回覆

Using defaultPref() shows the pref as default (i.e. not bold) with the new specified value on the about:config page, so the setting in the mozilla.cfg file isn't overruled for me by firefox.js or greprefs.js like you posted and the pref won't be saved to prefs.js.
Using pref() sets the pref to a user_set value and thus makes it appear bold and saves the value to prefs.js

Using defaultPref() shows the pref as default (i.e. not bold) with the new specified value on the about:config page, so the setting in the mozilla.cfg file isn't overruled for me by firefox.js or greprefs.js like you posted and the pref won't be saved to prefs.js.<br /> Using pref() sets the pref to a user_set value and thus makes it appear bold and saves the value to prefs.js
harryjohnston 1 個解決方法 11 個答案

The problem might be platform-specific then. I'll add a note to this effect on the bug. [No, that's not the reason, see my next comment.]

The problem might be platform-specific then. I'll add a note to this effect on the bug. [No, that's not the reason, see my next comment.]

由 harryjohnston 於 修改

harryjohnston 1 個解決方法 11 個答案

OK: defaultPref() doesn't work at all on Firefox 14.0.1, but usually (though not always) works in Firefox 15. I'm still trying to identify exactly what's going on in the latter case.

OK: defaultPref() doesn't work at all on Firefox 14.0.1, but usually (though not always) works in Firefox 15. I'm still trying to identify exactly what's going on in the latter case.

提出問題者

Hello

I wait a new version of firefox. I test with Firefox 17.0esr for Win 7 x64 and the defaultPref() seems to work now.

defaultPref("browser.startup.homepage", "http://www.xyz.com/"); doesn't work but i searched and found this page setting-the-default-firefox-homepage-with-autoconfig and it seems to work. Replace defaultPref("browser.startup.homepage", "http://www.xyz.com/"); by defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.xyz.com/");

Hello I wait a new version of firefox. I test with Firefox 17.0esr for Win 7 x64 and the defaultPref() seems to work now. defaultPref("browser.startup.homepage", "http://www.xyz.com/"); doesn't work but i searched and found this page [http://mike.kaply.com/2012/08/29/setting-the-default-firefox-homepage-with-autoconfig/ setting-the-default-firefox-homepage-with-autoconfig] and it seems to work. Replace defaultPref("browser.startup.homepage", "http://www.xyz.com/"); by defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.xyz.com/");