Js:添加收藏/设置默认首页

来源:互联网 发布:apple pencil 软件 pdf 编辑:程序博客网 时间:2024/05/16 16:22

添加收藏

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页特效观止|www.jscode.cn|---添加收藏</title>
</head>

<body>
右击鼠标查看代码

<p>代码一:<a onclick="window.external.AddFavorite(location.href, document.title);" title="网页特效" style="cursor:hand">收藏本页</a> </p>
<p><br>

代码二:<a href="javascript:window.external.AddFavorite('http://www.jscode.cn', '网页特效观止')">收藏本站</a>

</p>
<p>
<script language="javascript">
  function addFavorite(url,title){
    var fav_url = url;
 var fav_title = title;
 if (document.all && window.external){
   window.external.AddFavorite(fav_url,fav_title);
 }else if (window.sidebar){
   window.sidebar.addPanel(fav_title,fav_url,"");
 }else{
   alert("浏览器不支持,请手动加入收藏夹");
 }
  }
</script>
代码三:<a href="javascript:addFavorite('http://www.html.org.cn','网站标题');">添加收藏</a>
</p>
</body>

</html>


设置默认首页
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页特效|www.jscode.cn|---设置默认首页</title>
</head>

<body>
右击鼠标查看代码

<p>代码一:<span onclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.jscode.cn');"  style="CURSOR: hand">将本站设置为首页</a></span></p>
<p><br>

代码二:<a title="设置本站为浏览器首页" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.jscode.cn');" href="javascript:;">设为首页</a>

</p>

</body>

</html>

原创粉丝点击