var twoIndex = strTwo.lastIndexOf("&");//判断参数后面是否还有其他参数
if (twoIndex > 0)
strTwo = strTwo.substr(twoIndex);//获取后面参数包含"&"
else
strTwo = "";
result = strOne + parama + "=" + val + strTwo;
return result;
}
复制代码
调用方法:
//当前完整URL
var url = "<php>echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];</php>";
var t = changeURLPar(url,'keyword','大米CMS');
location.href = t;