-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddBookmark
32 lines (32 loc) · 1.2 KB
/
addBookmark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function addBookmark(obj) {
var url = window.location.href;
var title = document.title;
var osType = getOs();
if (osType == 'MSIE') {
window.external.addFavorite(url, title);
} else if (osType == 'Firefox') {
obj.setAttribute("rel", "sidebar"), obj.title = title, obj.href = url;
window.sidebar.addPanel(document.title, window.location.href, "");
} else if (osType == 'Safari') {
//chrome or apple
alert("请按ctrl+d收藏本站!");
}
}
function setHome(url){
if (document.all){
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(url);
}else if (window.sidebar){
if(window.netscape){
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}catch (e){
alert( "该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
}
}
if(window.confirm("你确定要设置"+url+"为首页吗?")==1){
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',url);
}
}
}