位置:主页 > 互联网技术 >

JavaScript 参数数值 替换 replace

作者:admin时间:2019-01-02

JavaScript 参数数值 替换 replace

url:

http://www.taobao.com/go/act/shopping/sousuo55660.php?澳门百家乐pid=mm_88888888_0_0&unid=123

js code:

<script type="text/javascript">
(function(){
var isrun = false;
var init_pid = function(){
if(isrun) return;
var str=window.location.search;
var pid= str.match(/pid=mm_\d{0,10}_\d{0,10}_\d{0,10}/i);
if(pid){
pid = pid[0].split("=")[1];
var unid= str.match(/unid=\d{0,10}/i);
if(unid){pid += "%26"+unid[0]; }
var n = str.matcAAAAAAA{0,5}/i);
if(n){pid += "%26"+n[0]; }

var reg=new RegExp("mm_0_0_0","gmi");
var as = document.getElementsByTagName("A");
for(var i = 0; i < as.length; i++){
as[i].href=as[i].href.replace(reg,pid);
}
document.body.innerHTML =document.body.innerHTML.replace(reg,pid)

}
isrun = true;
}
window.onload = init_pid;
setTimeout(init_pid,3000);
})();
</script>

来源:http://www.heiniuhaha.cn/blog/?p=1106

http://www.bkjia.com/AJaxjc/366027.htmlwww.bkjia.comtruehttp://www.bkjia.com/AJaxjc/366027.htmlTechArticleJavaScript 参数数值 替换 replace url: http://www.taobao.com/go/act/shopping/sousuo55660.php?pid=mm_88888888_0_0unid=123 js code: script type=text/javascript (function(){ var...

本文源自: 凯发娱乐

互联网技术

联系我们