home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 December
/
PCWorld_2005-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-0.exe
/
chrome
/
browser.jar
/
content
/
browser
/
homeButton.js
< prev
next >
Wrap
Text File
|
2005-09-26
|
2KB
|
75 lines
function homeButtonSetHomePageToCurrentPage()
{
dump("\nhomeButtonSetHomePageToCurrentPage function called...\n\n");
var rv;
var url = "";
var browser = this.document.getElementById("content");
url = browser.currentURI.spec;
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
rv = prefs.setCharPref("browser.startup.homepage", url);
rv = prefs.savePrefFile(null);
dump("\nPreferences written to file\n");
}
function homeButtonSetHomePageToBookmark()
{
dump("\homeButtonSetHomePageToBookmark function called...\n\n");
var rv = { url: null };
openDialog("chrome://browser/content/bookmarks/selectBookmark.xul", "",
"centerscreen,chrome,modal=yes,dialog=yes,resizable=yes", rv);
if (rv.url) {
dump("\nsetting home page to " + rv.url + "\n");
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
rv = prefs.setCharPref("browser.startup.homepage", rv.url);
rv = prefs.savePrefFile(null);
dump("\nPreferences written to file\n");
}
}
function homeButtonSetHomePageToBlank(){
dump("\homeButtonSetHomePageToBlank function called...\n\n");
var url = "about:blank";
dump("\nsetting home page to " + url + "\n");
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
rv = prefs.setCharPref("browser.startup.homepage", url);
rv = prefs.savePrefFile(null);
dump("\nPreferences written to file\n");
}
//the Options dialog box sets it's own preferences, therefore this function is only intended
//to be called from the main chrome area.
function homeButtonSetHomePageToCurrentTabs()
{
dump("\homeButtonSetHomePageToCurrentTabs function called...\n\n");
var rv;
var newHomePage = "";
var browser;
browser = this.document.getElementById("content");
var l = browser.mPanelContainer.childNodes.length; //number of currently open tabs
for (var i = 0; i < l; i++) {
if (i) {
newHomePage += "|";
}
newHomePage += browser.getBrowserAtIndex(i).webNavigation.currentURI.spec;
}
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
rv = prefs.setCharPref("browser.startup.homepage", newHomePage);
rv = prefs.savePrefFile(null);
}