js menu 绑定

window.location.hostname ;

window.location.pathname;

 方法:通过window.location.pathname获得浏览器URL的路径部分。得到路径的第一个字段。

[].indexOf || (Array.prototype.indexOf = function(v){
    for(var i = this.length; i-- && this[i] !== v;);
        return i;
    }
);//ie不支持indexof扩展一下
 var url={
	 
                ary1:["index.html","game","news","tweets","blogs","gallery","servers","clans","support"],
                geturl:function(){
                    var urlpath=window.location.pathname;
                    urlpath= urlpath.substr(1)
                    var ary_url=urlpath.split("/")
                    this.key=ary_url[0]
                    this.index=this.ary1.indexOf(this.key)
					
                },
                change:function(){
                    var i=this.index
					
                    $(".menu>ul>li>a").eq(i).css("color","#fdef07")
                }
            }
           url.geturl()
           url.change()
原文地址:https://www.cnblogs.com/breakdown/p/2693829.html