javascript:お気に入りに追加してトップページに設定します.

3115 ワード

//      ,     ie
function addBookmark(url,title) {
if (window.sidebar) {
   window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
   window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
   return true;
}
}

//    ,     ie
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);
}
}