问题
I am using a xulrunner-1.9.2.12.en-US.win32 for an app I am creating. I want the user to be able to change the colours of the app using something similar to the "tools, options, content, colors" menu in firefox.
I am using a prefwindow to set browser.display.background_color using a colour picker. If I look at chrome://global/content/config.xul I see that the value for this property has been correctly changed, however, I see no corresponding change in the web page look and feel. If I view this web page in firefox and make the same changes through tools, options etc, the page changes as expected.
I changed my prefs.js file to the following as a test, with no result: pref("browser.display.foreground_color", "#000000");
pref("browser.display.background_color", "#FF0000");
pref("browser.display.use_document_colors", false);
pref("browser.display.use_system_colors", false);
pref("browser.preferences.instantApply", false);
pref("browser.preferences.animateFadeIn", false);
I will also add my xul file - appologies for the length of the post:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="colorOptions" label="Colours">
<preferences>
<preference id="browser.display.foreground_color" name="browser.display.foreground_color" type="string"/>
<preference id="browser.display.background_color" name="browser.display.background_color" type="string"/>
</preferences>
<groupbox flex="1">
<caption label="Colour preferences"/>
<label value="Background colour" control="bgColour"/>
<colorpicker type="button" id="bgColour"preference="browser.display.background_color"/>
<label value="Foreground colour" control="fgColour"/>
<colorpicker type="button" id="fgColour" preference="browser.display.foreground_color"/>
<label value="Random colour" control="col"/>
<colorpicker type="button" id="col"/>
</groupbox>
</prefpane>
</prefwindow>
Any ideas? Thanks in advanced, Ant
回答1:
In my application using xulrunner 1.9.0.3082 I had to change the file
defaults/prefs/xulrunner.js
With the following additional line all texts are shown in a beautiful blue:
pref("browser.display.foreground_color", "#00A4FA");
Any changes to the file pref.js were not successful!
回答2:
I think this may be a bug in xulrunner.
If I set xulrunner to open http://www.google.com and open the about:config panel and set
browser.display.background_color and
browser.display.use_document_colors
I see no change in the web page.
Doing the same thing with Firefox yeilds the expected results.
I have entered a bug report and will post any feedback.
回答3:
Since firefox is using Xulrunner too, I guess the bug would be present in Firefox too if it were one. Are you using the same version of firfox and xulrunner?
According to this page you need to set browser.display.use_system_colors to false so that the background color have an effect. Maybe that's why it did not change in xulrunner.
Considering your code I don't see why it does not work but there is no space between "bgcolour" and "preference" maybe that could be an error.
来源:https://stackoverflow.com/questions/4508762/setting-xulrunner-browser-preferences