0
点赞
收藏
分享

微信扫一扫

HTML接收?号后参数和js获取工程名

1.获取工程名和获取参数JS代码
function GetRequest()

 

    {  

    var url = location.search; // 获取url中"?"符后的字串  

    var theRequest = new Object();  

    if(url.indexOf("?") != -1)  

    {  

       var str = url.substr(1);  

       str = decodeURIComponent(str);

        strs = str.split("&");  

       for(var i = 0; i < strs.length; i ++)  

        {  

          theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  

        }  

    }  


    return theRequest;  

   }


   var Request = new Object();

   Request = GetRequest();

   if (Request.resultStr == undefined) {

    return ;

   } else if (Request.resultStr != '') {

    var obj = eval("("+Request.resultStr+")");

    if (obj.flag == 1) {

     window.location.href = "manager/manager_managerCenter.action";

    }else {

     alert(obj.message);

    }

   }  

});
</pre><pre name="code" class="javascript"><pre name="code" class="javascript">// 获取工程名
function getContextPath() {
var contextPath = document.location.pathname;
var index =contextPath.substr(1).indexOf("/");
contextPath = contextPath.substr(0,index+1);
delete index;
return contextPath;
}





举报

相关推荐

0 条评论