从地址栏获取参数

//点击从当前页面开始传递goodsID----
$(document).on("tap",".goodImg",function(){
var tmpGoodId = $(this).attr("goodId");
window.location.href="shangpin.html?goodsID="+tmpGoodId+"";

});
-------shangping.html页面获取goodsID;
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)($|&)");
var strArr = window.location.search.substr(1).match(reg);
if(strArr != null) return unescape(strArr[2]);
return null;
}
var goodsID=getUrlParam('goodsID')//-----------调用函数将goodsID反回给goodsID;

posted @ 2017-06-16 16:54  千年鱼  阅读(335)  评论(0编辑  收藏  举报