如何实现点击设为首页,加入收藏夹效果

设为首页

<a href="#" onclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.baidu.com');" style="CURSOR: hand">设为首页</a>


加入收藏

方法一:
<a onClick="window.external.addFavorite('http://www.baidu.com/','百度');return false;" href="'http://www.baidu.com/" target="mainFrame">加入收藏</a>


方法二:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>none</title>
<style type="text/css" media="screen">
<!--
@charset "utf-8";
* {margin:0;padding:0;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:small;}
ul {list-style-type:none;}
-->
</style>
<script type="text/javascript">
<!--
window.onload=function() {
var favorite_hook=document.createElement('a');
favorite_hook.setAttribute('href','#');
favorite_hook.style.width='128px';
favorite_hook.style.height='160px';
favorite_hook.style.backgroundImage='url(http://img.baidu.com/img/img-jg.gif)';
favorite_hook.style.position='absolute';
document.body.appendChild(favorite_hook);
if (document.addEventListener) {
favorite_hook.addEventListener('click',function() {
window.sidebar.addPanel('百度','http://www.baidu.com',"");
return false;
},false);
}
else {
favorite_hook.attachEvent('onclick',function() {
window.external.addFavorite('http://www.baidu.com/','百度');
return false;
});
}
}
-->
</script>
</head>
<body>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值