【www.gdgbn.com--js教程】

js 获取中文标题解决乱码问题

function gettitle(){
    var title;
    if (typeof(encodeuricomponent)=="function"){
        if (document.title){
            if (window.regexp){
                var tire=new regexp("^"+window.location.protocol+"//"+window.location.hostname+"s-s");
                title=document.title.replace(tire,"");
            }
        }else{
            title=document.title;
        }
        title=encodeuricomponent(title);
    }else{
        title="";
    }
    return title;
}

本文来源:http://www.gdgbn.com/wangyezhizuo/29353/