| Summary: | JavaScript method window.home() broken | ||
| Creator: | kko | Date: | 2008-04-19 06:13:28 |
| Project: | K-Meleon | Owner: | dorian |
| Status: | Fixed | Severity: | Normal |
| Version: | 1.5b1 | Target Version: | 1.5b2 |
User-agent: K-Meleon/1.5
Gecko offers the window.home() method to make the browser navigate to its home page from JavaScript. (see http://developer.mozilla.org/en/docs/DOM:window.home )
A hyperlink like <a href="javascript:window.home()">Home Page</a> should direct you to your home page. It does in Firefox and SeaMonkey, but not in K-Meleon. In the latter it directs you to http://www.mozilla.org/ .
Method window.home() is evaluating preference browser.startup.homepage which is not set in km. Its default value (in SeaMonkey) is chrome://navigator-region/locale/region.properties (in km this is pointing to \chrome\xx-YY.jar!/embed/locale/YY/navigator-region/region.properties). In this file, string homePageDefault is set to http://www.mozilla.org/ .
To make window.home() have the desired effect in km, browser.startup.homepage must be set to the same value as kmeleon.general.homePage.
Possible workaround: Synchronize browser.startup.homepage and kmeleon.general.homePage with a macro.
Chrome, macros and default prefs are updated. Fixed from my side.
Some remarks:
JavaScript method window.home() is working like this:
- When pref browser.startup.homepage has a user-set value, the pref is of type nsISupportsString i.e. its value is already the URL to be opened.
- Otherwise, the pref is of type nsIPrefLocalizedString i.e. its actual value is the chrome URL of a properties file which contains a property with the same name as the pref and the value of this property is returned as the value of the pref.
- In case browser.startup.homepage is not set at all, an internal default value is used. Ours is currently http://kmeleon.sourceforge.net/start . resource:///readme.html or http://kmeleon.sourceforge.net/ would be sufficient too.
See nsGlobalWindow::Home() [ http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#4333 ]
Our ID_NAV_HOME should work the same way. Everything is prepared. In kmeleon.js, the default value for browser.startup.homepage is set to the correct chrome URL. The referenced properties file (part of the locale) is set up correctly pointing to resource:///readme.html (must be resource:///locales/xx-YY/readme.html if not en-US).
Migrating the home page url from the old pref (kmeleon.general.homePage) to the new one (browser.startup.homepage) is only necessary when it's user-set. Otherwise you don't need to do anything.
[Changed Owner from ".Nobody" to "dorian"]
Currently, kmeleon pref system can't know if a pref is "user set" or not, and I don't think I'll take the trouble to implement it just for that.
[Changed Status from "Open" to "Fixed"]
[Changed Target from "Unknow" to "1.5b2"]