設爲首頁and加入收藏js
function addFavorite() {
if(document.all) {
try {
window.external.addFavorite(window.location.href, document.title);
} catch(e) {
alert("加入收藏失敗,請使用Ctrl+D進行添加");
}
} else if(window.sidebar) {
window.sidebar.addPanel(document.title, window.location.href, "");
} else {
alert("加入收藏失敗,請使用Ctrl+D進行添加");
}
}
function setHomepage() {
if(document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage(window.location.href);
} else if(window.sidebar) {
if(window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch(e) {
alert("該操作被瀏覽器拒絕,如果想啓用該功能,請在地址欄内輸入 about:config,然後將項 signed.applets.codebase_principal_support 值該爲true");
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', window.location.href);
} else {
alert('您的瀏覽器不支持自動自動設置首頁, 請使用瀏覽器菜單手動設置!');
}
}