user.js doesn't work

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kj

    user.js doesn't work




    I don't know what I'm doing wrong.

    I have a file called user.js in my Mozilla (or Firefox) directory,
    and this file contains the following code:

    user_pref("brow ser.throbber.ur l", "http://news.google.com/");

    function foo() {
    alert("foo");
    }

    And yet, when I start Mozilla (or Firefox), and look at the listing
    from about:config, I see that browser.throbbe r.url is still set to
    the default value (e.g. http://www.mozilla.org/products/firefox/start),
    not the value I set it to in user.js. Similarly, if I type the
    following in the location bar:

    javascript:foo( )

    I get the error "Error: foo is not defined" in the JavaScript
    console. I've tried this both on Windows and on Linux. On Windows,
    the user.js file is in

    Documents and Settings > yourstruly > Application Data[color=blue]
    > Mozilla > Firefox > Profiles > default###[/color]

    and the one on Linux it is in

    ~/.mozilla/yourstruly/###.slt

    What am I doing wrong?

    kj

    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
  • Grant Wagner

    #2
    Re: user.js doesn't work

    kj wrote:
    [color=blue]
    > I don't know what I'm doing wrong.
    >
    > I have a file called user.js in my Mozilla (or Firefox) directory,
    > and this file contains the following code:
    >
    > user_pref("brow ser.throbber.ur l", "http://news.google.com/");
    >
    > function foo() {
    > alert("foo");
    > }
    >
    > And yet, when I start Mozilla (or Firefox), and look at the listing
    > from about:config, I see that browser.throbbe r.url is still set to
    > the default value (e.g. http://www.mozilla.org/products/firefox/start),
    > not the value I set it to in user.js. Similarly, if I type the
    > following in the location bar:
    >
    > javascript:foo( )
    >
    > I get the error "Error: foo is not defined" in the JavaScript
    > console. I've tried this both on Windows and on Linux. On Windows,
    > the user.js file is in
    >
    > Documents and Settings > yourstruly > Application Data[color=green]
    > > Mozilla > Firefox > Profiles > default###[/color]
    >
    > and the one on Linux it is in
    >
    > ~/.mozilla/yourstruly/###.slt
    >
    > What am I doing wrong?
    >
    > kj[/color]

    prefs.js seems to be the file that contains the customized values, not
    user.js. I've seen all sorts of references to "user.js" on the Web, but all
    _my_ customized about:config values are coming from prefs.js, not user.js.
    *Maybe* user.js in the "chrome" directory under the profile would do what
    you want, I can't be bothered testing it when changes to prefs.js do what I
    want.

    As for why your custom function isn't working, I have no idea. My guess is
    it's a scope issue. The contents of prefs.js do not execute in the same
    namespace/scope as regular scripts in the browser. If prefs.js were in the
    same namespace/scope, you could run "javascript:use r_pref(...)" in the
    Address Bar, which I just tested, and does not work.

    --
    Grant Wagner <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq


    Comment

    Working...