如何實現點擊設爲首頁,加入收藏夾效果

設爲首頁

<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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章