<html>
<head>
<script type=”text/javascript”>
function addFav(卡塔尔国{   // 到场收藏夹
if (document.all) {
   window.external.addFavorite(window.location.href, document.title);
} else if (window.sidebar) {
   window.sidebar.addPanel(document.title, window.location.href, “”);
}
}

复制代码 代码如下:

function setHomepage(卡塔尔{  
// 设置首页
if (document.all) {
   document.body.style.behavior = ‘url(#default#homepage)’;
   document.body.setHomePage(window.location.href);
} else if (window.sidebar) {
   if (window.netscape) {
    try {
    
netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”);
    } catch(e) {
     alert(“该操作被浏览器拒却,要是想启用该意义,请在地方栏内输入
about:config,然后将项 signed.applets.codebase_principal_support
值该为true”);
    }
   }
var prefs =
Components.classes[‘@mozilla.org/preferences-service;1’].getService(Components.interfaces.nsIPrefBranch);
   prefs.setCharPref(‘browser.startup.homepage’,
window.location.href);
}
}
</script>
</head>
<body>
澳门葡萄京官方网站 ,<a href =”javascript:void(0卡塔尔(قطر‎” onclick =”setHomepage(卡塔尔”> 设为首页
</a>
<a href=”javascript:void(0卡塔尔(قطر‎” onclick =”addFav(卡塔尔(قطر‎”> 出席收藏
</a>

<html>
   <head>
     
<title>JavaScript设置首页和收藏页面(包容IE和火狐)</title>
      <script>
      //url:要收藏的链接;title:收藏项的称谓
      function AddFavorite(url,title)
      {
         //假设url可能title为空,暗中同意为当前页面url和title。
         if(!(url&&title))
         {
            url=document.URL;
            title=document.title; 
         }

</body>
</html>
这段代码为何设为首业不相称火狐 其余的都不利

         if (document.all)//IE
         {
               window.external.addFavorite(url,title);
         }
         else if (window.sidebar)//火狐
         {
            window.sidebar.addPanel(title, url, “”);
         }
      }

 

      //url:要设置为首页的链接
      function SetHomepage(url)
      {
         //就算url为空,默觉妥善前页面url。
         if(!url)
         {
            url=document.URL;
         }

         if (document.all)//IE 
         {
            document.body.style.behavior = ‘url(#default#homepage)’;
            document.body.setHomePage(url);
         }
         else if (window.sidebar)//火狐
         {
            if (window.netscape)
            {
               try
               {
                 
window.netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”);
               }
               catch (e)
               {
                 
alert(“此操作被浏览器谢绝!请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]的值设置为’true’,双击就能够。”卡塔尔国;
               }
            }
            var prefs =
Components.classes[‘@mozilla.org/preferences-service;1’].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref(‘browser.startup.homepage’, url);
         }
      } 
      </script>
   </head>
   <body>
      <a onClick=”SetHomepage(”卡塔尔国”
title=”设为首页” href=”javascript:”>设为首页</a>
      <a onClick=”AddFavorite(”)”
title=”收藏” href=”javascript:”>收藏</a>
   </body>
</html>

代码如下: html head
titleJavaScript设置首页和收藏页面(宽容IE和火狐)/title script
//url:要收藏的链接;title:收藏项的名称 function…