How can I set default homepage in FF and Chrome vi

2019-01-01 06:05发布

I have a code that works only in IE anb I was looking for something similar in FF and Chrome to set user's default homepage through a link 'click here to make this site your default homepage', but so far I didn't find anything.

Does anyone know how to do this?

7条回答
骚的不知所云
2楼-- · 2019-01-01 06:38
function addBookmarkForBrowser() {    
   if (document.all) {    
      window.external.AddFavorite(document.location.href , document.title);
   } else {    
      var ea = document.createEvent("MouseEvents");    
      ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);    
      var eb = document.getElementsByTagName("head")[0];    
      eb.ownerDocument getter = new function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");    
      eb.dispatchEvent(ea);
   }    
}

and

<a href="javascript:addBookmarkForBrowser();">Add to Favorites</a>
查看更多
登录 后发表回答