设置为首页加入收藏的js代码,兼容ie,firefox...
时间:2010-08-17 来源:ytmf007
<script type="text/javascript">
<!--
var addBookmark = function(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url, "");
} else if (document.all) {
window.external.AddFavorite(url, title);
} else if (window.opera && window.print) {
return true;
}
};
var setHomepage = function() {
if (document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage('http://www.91igame.com');
} 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', 'http://www.91igame.com');
}
};
//-->
<div class="header_right">
<div class="header_tools"><span class="header_tools_a"><a
href="javascript:addBookmark('星游在线','http://www.91igame.com');">加入收藏</a></span> <span class="header_tools_b"><a href="javascript:setHomepage()">设为首页</a></span>
</div>