universal javascript for set homepage functionality

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

Is there any javascript that works on almost all browsers for setting a webpage as homepage?

I am using below one. But it only works for i.e. and mozilla

    var flag = false;     function setHomepage(web)     {         if (document.all)         {             document.body.style.behavior='url(#default#homepage)';             document.body.setHomePage(web);          }         else if (window.sidebar)         {             if(window.netscape)             {                 try                 {                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");                     flag = true;                   }                   catch(e)                   {                       alert("This action was aviod by your browser. If you want to enable please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");                 }             }              if(flag)             {                 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);                 prefs.setCharPref('browser.startup.homepage',web);             }               }     } 

回答1:

This is an earlier discussion thread on the subject: How can I set default homepage in FF and Chrome via javascript?

Basically, there's no universal support and changing the homepage is generally considered a very annoying thing to do.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!