兼容FF 加入收藏夹和设为首页

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>兼容FF 加入收藏夹和设为首页</title>
<script language="javascript">
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL," ");
        }
        catch (e)
        {
            alert('加入收藏失败,请使用Ctrl+D进行添加');
        }
    }
}

function SetHome(obj,vrl){
 try{
   obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
 
 }
 catch(e){
  alert("抱歉!您的浏览器不支持直接设为首页。请在浏览器地址栏输入about:config 并回车然后将[signed.applets.codebase_principal_support]设置为true,点击加入收藏后忽略安全提示,即可设置成功");
}

 }

</script>
</head>
<body>
<a onClick="AddFavorite('http://www.baidu.com','百度')">加入收藏</a>
<a target="_top" onClick="SetHome(this,'http://www.baidu.com')" href="javascript:void(0)">设为首页</a>

</body>
</html>

posted @ 2011-04-21 10:32  ___.Net  阅读(496)  评论(0编辑  收藏  举报