分享/收藏/设为主页/搜索

收藏结构

<div class="header">
    <span id="set_fav">加入收藏</span>
</div>

收藏JS代码

 <script>
 //Add Favorites
var ele=document.getElementById("set_fav");
    ele.onclick=function(){
        var ua = navigator.userAgent.toLowerCase(),
            url =location.href,
            sitename =document.title;
        if(ua.indexOf("msie 8")>-1){
                external.AddToFavoritesBar(url,sitename,"");//IE8
        }else{
            try{
                window.external.addFavorite(url,sitename);
            }catch(e){
              try{
              window.sidebar.addPanel(sitename,url,"");//firefox
              }catch(e){
                alert("加入收藏失败,请使用Ctrl+D进行添加");
              }
            }
        }
        return false;

    }
</script>

 

 

 

分享代码---百度搜索百度分享,选择需要的分享代码,

<div id="share">
        <div class="bdsharebuttonbox">
            <a href="#" class="bds_more" data-cmd="more" style="background:none;">分享</a>
        </div>
</div>

 

分享JS代码,写在html页面里面

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>

 

 

 

设为主页结构

<span id="set_fav">加入收藏</span>

分享JS代码

<script>

// set_home
var set=document.getElementById("set_home");
    set.onclick=function(){
        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);  
            }else{  
                alert('您的浏览器不支持自动自动设置首页, 请使用浏览器菜单手动设置!');  
            }
    }

</script>

 

 

 

搜索结构

<div class="header">
    <h1>
        <a href="#">环球财经|社会</a>
    </h1>
    <div class="search">
        <form target="_blank" action="http://search.2258.com/cse/search">
            <input type="hidden" value="4791414781898427824" name="s">
            <input id="smart_input" class="s_ipt" type="text" name="q">
            <input class="s_btn" type="submit" value="">
        </form>
    </div>
</div>

 

posted on 2014-08-16 11:36  鬼鬼丫404  阅读(81)  评论(0编辑  收藏  举报

导航