<!--设置首页-->
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <a οnclick="SetHome(this,window.location.href);" style="cursor: pointer" href="javascript:;">设为首页</a> 2 3 function SetHome(obj, vrl) { 4 try { 5 obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl) 6 } catch (e) { 7 if (window.netscape) { 8 try { 9 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") 10 } catch (e) { 11 alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。") 12 } 13 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 14 prefs.setCharPref('browser.startup.homepage', vrl) 15 } 16 } 17 }
<!--添加收藏-->
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <a οnclick="AddFavor('http://www.baidu.com/','百度');">添加收藏</a> 2 function AddFavor(sURL, sTitle) { try { window.external.addFavorite(sURL, sTitle); } catch (e) { try { window.sidebar.addPanel(sTitle, sURL, ""); } catch (e) { alert("加入收藏失败,当前浏览器不支持,请手动收藏本页!"); } } return false; }