<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>加入收藏 设为首页代码</title>
</head>
<body>
<div> 方法1:<a οnclick="SetHome(window.location)" href="javascript:void(0)">设为首页</a> | <a
οnclick="AddFavorite(window.location,document.title)" href="javascript:void(0)"> 加入收藏</a>
<script type="text/javascript" language="javascript">
//加入收藏
function AddFavorite(sURL, sTitle) {
sURL = encodeURI(sURL);
try {
window.external.addFavorite(sURL, sTitle);
} catch (e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
} catch (e) {
alert("加入收藏失败,请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
}
}
}
//设为首页
function SetHome(url) {
if (document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage(url);
} else {
alert("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");
}
}
</script>
</div>
<br />
方法2: <a οnclick="javascript:addfavor();" title="加入收藏" href="javascript:void(0)">加入收藏</a>
<script type="text/javascript">
function addfavor() {
var title = window.parent.document.title;
var url = window.parent.location;
if (confirm("网站名称:" + title + "\n网址:" + url + "\n确定添加收藏?")) {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie 8") > -1) {
external.AddToFavoritesBar(url, title, ''); //IE8
} else {
try {
window.external.addFavorite(url, title);
} catch (e) {
try {
window.sidebar.addPanel(title, url, ""); //firefox
} catch (e) {
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
}
return false;
}
</script>
<br />
<br />
方法3:(此方法不<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐) <a href="#" οnclick="javascript:window.external.AddFavorite('http://www.v404.cn','网站频道')"
title="加入收藏">加入收藏</a> <br />
<br />
方法4:(<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐)指定域名 <a href="javascript:void(0);" οnmοusedοwn="addlove(this, 'http://www.v404.cn', '网站频道')"> 加入收藏</a>
<script type="text/javascript">
var addlove = function (obj, url, title) {
var e = window.event || arguments.callee.caller.arguments<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>;
var B = {
IE: /MSIE/.test(window.navigator.userAgent) && !window.opera
, FF: /Firefox/.test(window.navigator.userAgent)
, OP: !!window.opera
};
obj.onmousedown = null;
if (B.IE) {
obj.attachEvent("onmouseup", function () {
try {
window.external.AddFavorite(url, title);
window.event.returnValue = false;
} catch (exp) { }
});
} else {
if (B.FF || obj.nodeName.toLowerCase() == "a") {
obj.setAttribute("rel", "sidebar"), obj.title = title, obj.href = url;
} else if (B.OP) {
var a = document.createElement("a");
a.rel = "sidebar", a.title = title, a.href = url;
obj.parentNode.insertBefore(a, obj);
a.appendChild(obj);
a = null;
}
}
};
</script>
<br />
<br />
5.此方法不<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐和谷歌浏览器: <span style="cursor: pointer" οnclick="window.external.addFavorite('http://www.v404.cn','网站频道')"
title="新浪">收藏本站</span>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>加入收藏 设为首页代码</title>
</head>
<body>
<div> 方法1:<a οnclick="SetHome(window.location)" href="javascript:void(0)">设为首页</a> | <a
οnclick="AddFavorite(window.location,document.title)" href="javascript:void(0)"> 加入收藏</a>
<script type="text/javascript" language="javascript">
//加入收藏
function AddFavorite(sURL, sTitle) {
sURL = encodeURI(sURL);
try {
window.external.addFavorite(sURL, sTitle);
} catch (e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
} catch (e) {
alert("加入收藏失败,请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
}
}
}
//设为首页
function SetHome(url) {
if (document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage(url);
} else {
alert("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");
}
}
</script>
</div>
<br />
方法2: <a οnclick="javascript:addfavor();" title="加入收藏" href="javascript:void(0)">加入收藏</a>
<script type="text/javascript">
function addfavor() {
var title = window.parent.document.title;
var url = window.parent.location;
if (confirm("网站名称:" + title + "\n网址:" + url + "\n确定添加收藏?")) {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie 8") > -1) {
external.AddToFavoritesBar(url, title, ''); //IE8
} else {
try {
window.external.addFavorite(url, title);
} catch (e) {
try {
window.sidebar.addPanel(title, url, ""); //firefox
} catch (e) {
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
}
return false;
}
</script>
<br />
<br />
方法3:(此方法不<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐) <a href="#" οnclick="javascript:window.external.AddFavorite('http://www.v404.cn','网站频道')"
title="加入收藏">加入收藏</a> <br />
<br />
方法4:(<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐)指定域名 <a href="javascript:void(0);" οnmοusedοwn="addlove(this, 'http://www.v404.cn', '网站频道')"> 加入收藏</a>
<script type="text/javascript">
var addlove = function (obj, url, title) {
var e = window.event || arguments.callee.caller.arguments<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>;
var B = {
IE: /MSIE/.test(window.navigator.userAgent) && !window.opera
, FF: /Firefox/.test(window.navigator.userAgent)
, OP: !!window.opera
};
obj.onmousedown = null;
if (B.IE) {
obj.attachEvent("onmouseup", function () {
try {
window.external.AddFavorite(url, title);
window.event.returnValue = false;
} catch (exp) { }
});
} else {
if (B.FF || obj.nodeName.toLowerCase() == "a") {
obj.setAttribute("rel", "sidebar"), obj.title = title, obj.href = url;
} else if (B.OP) {
var a = document.createElement("a");
a.rel = "sidebar", a.title = title, a.href = url;
obj.parentNode.insertBefore(a, obj);
a.appendChild(obj);
a = null;
}
}
};
</script>
<br />
<br />
5.此方法不<a href="http://www.v404.cn/search/?/兼容/" title="搜索“兼容”的相关文章" target="_blank" class="sitelink">兼容</a>火狐和谷歌浏览器: <span style="cursor: pointer" οnclick="window.external.addFavorite('http://www.v404.cn','网站频道')"
title="新浪">收藏本站</span>
</body>
</html>