访问GOOGLE首页有一个加为首页的功能,当你加了GOOGLE为IE首页以后这个链接就没有了,你把IE首页改成不是GOOGLE的时候加为首页的链接又会出现,我知道有一个javascritp有一个方法是isHomePage,但我试过不管怎么样都是返回flase,GOOGLE是怎么实现的?

解决方案 »

  1.   

    <a class=top href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.google.cn/');" >设为首页</a> 
      

  2.   

    使用JS只能得到ie的首页。
    var WShell = new ActiveXObject("WScript.Shell"); 
    MainUrl = WShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page");
      

  3.   

    设置当前地址为首页
    window.setHomePage(window.location.href);
      

  4.   


    例子:
    <html>
    <head>
    <title>检测是否已设为主页</title>
    <script language="javascript">
    function checkit(){
    var objr=document.getElementById("isHome");
    objr.style.behavior="url(#default#homepage)";
    if(!(objr.isHomePage(location.href))){
    document.getElementById("isHome").style.display="block";
    }else{
    document.getElementById("isHome").style.display="none";
    }
    }
    function isHome(obj){
    obj.style.behavior="url(#default#homepage)";
    obj.setHomePage(location.href);  //将当前页设为主页。
    //特别注意:指定的地址必须与当前页面在同一个网站!
    //否则达不到检测是否已设为主页的效果。
    location.reload();
    }
    </script>
    </head>
    <body onLoad="checkit()">
    <span style="cursor:pointer;font-weight:bold" onClick="isHome(this)" id="isHome"><u>把当前页设为我的主页</u></span>
    </body>
    </html>
      

  5.   

    See here! Source of Google index:
      

  6.   


      <p id=shf0 style=display:none;behavior:url(#default#homePage)>
      <font size=-1>
      <a href="/aclk?sa=L&ai=CGye6n1o2SqHuIczfkAXcz5T0BsX4n3zdqqjHCs2tk5cREAEgwVRQvpyhyfj_____AWCdAaoECU_QazWdakhFJg&num=1&sig=AGiWqtzqFUFWw1YjuE2cDQD5ZRC4dAdOnw&q=/mgyhp.html" onclick=xz()>把Google设为我的主页</a></p><script>(function(){
      var a=document.getElementById("shf0"),b="http://www.google.cn/";
      try{
    a.isHomePage(b)||(a.style.display="block")
      }catch(z){}
      window.xz=function(){
      try{
    a.setHomePage(b);
    var c=new Image;
    c.src="/gen_204?mgmhp=shf0&ct=c&cd="+a.isHomePage(b);
    window.wy=c
      }catch(z){}
      }
      })();</script></font><p>
      

  7.   


    <script>
    var oHomePage,oCodeDiv,oURL;
    var sHomePage;
    function rdl_Verify(){
    var sHomePage=oURL.value;
    var bIs=oHomePage.isHomePage(sHomePage);
    with (oCodeDiv) if (bIs) innerText=sHomePage+"是您的默认主页"; else innerText=sHomePage+"不是您的默认主页";
    }
    function rdl_Set(){
    var sHomePage=oURL.value;
    oHomePage.setHomePage(sHomePage);
    }
    function window.onload(){
    oHomePage=document.all("idHomePage");
    oCodeDiv=document.all("idCodeDiv");
    oURL=document.all("idURL");
    }
    </script>
    <rdl:homepage id="idHomePage" />
    <table><tr>
    <td><input type=text size=30 value="http://www.dhtmlet.com" id=idURL></td>
    <td><input type=button value=" 检测 " onclick="rdl_Verify();"></td><td><input type=button value=" 设置 " onclick="rdl_Set();"></td>
    </tr></table>
    <br>
    <br>
    <div id=idCodeDiv>请确认输入框内的url地址然后点击「检测」按钮。</div>