代码片段

1.给来自搜索引擎的用户展示不同的页面

<script>
 var s=document.referrer;
 if(s.indexOf("baidu")>0||s.indexOf("haosou")>0||s.indexOf("google")>0||s.indexOf("yahoo")>0||s.indexOf("sogou")>0||s.indexOf("youdao")>0||s.indexOf("bing")>0)
 {
 self.location="http://fengtalk.com/?se";
 }
</script>

2.JS判断访客城市然后跳转

<script type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>     
<script type="text/javascript">     
var t = remote_ip_info;     
 if( t.province == '广东' )
     {  
window.location='index.html'; 
      } 
</script>

3.active

$(function(){
    var url = window.location.pathname, 
        urlRegExp = new RegExp(url.replace(/\/$/,'') + "$"); // create regexp to match current url pathname and remove trailing slash if present as it could collide with the link in navigation in case trailing slash wasn't present there
        // now grab every link from the navigation
        $('.menu a').each(function(){
            // and test its normalized href against the url pathname regexp
            if(urlRegExp.test(this.href.replace(/\/$/,''))){
                $(this).addClass('active');
            }
        });

});

4.网站公安备案

<div class="ba">
    <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43011102000188">
        <img src="images/ghs.png">
        <p>湘公网安备 43011102000188号</p>
    </a>
</div>
.ba {
    width:241px;
    margin:0 auto;
    padding: 0;
}

.ba a {
    display:inline-block;
    text-decoration:none;
    height:20px;
    line-height:20px;
}

.ba img {
    float: left;
}

.ba p {
    float:left;
    height:20px;
    line-height:20px;
    margin: 0px 0px 0px 5px;
    color:#666666;
}