武林网(www.vevb.com)文章简介:支持火狐,IE6.ie7.ie8.ie9的收藏网站代码。
以下为详细代码
<script>
var HomepageFavorite = {
//设为首页
Homepage: function () {
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");
history.go(-1);
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', window.location.href);
}
}
,
//加入收藏
Favorite: function Favorite(sURL, sTitle) {
try {
window.external.addFavorite(sURL, sTitle);
}
catch (e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e) {
alert("加入收藏失败,请手动添加.");
}
}
}
}
</script>
支持火狐,IE6.ie7.ie8.ie9的加入收藏/设为首页代码
<a href="javascript:HomepageFavorite.Homepage()" _fcksavedurl="javascript:HomepageFavorite.Homepage()" >设为首页</a>
<a href="javascript:HomepageFavorite.Favorite(window.location.href, document.title)" _fcksavedurl="javascript:HomepageFavorite.Favorite(window.location.href, document.title)" >加入收藏</a>
新闻热点
疑难解答