js获取href跳转页面传过来的参数

qingyingfei 2012-10-16 11:41:36
jq.ajax({
type:"get",
url:"../ashx/indexLoad.ashx",
data:"m=0",
async:false,
success:function(msg)
{
var temp=eval("("+msg+")");
if(temp.code==1)
{
for(var i=0;i<temp.message.List.length;i++)
{
content+="<li><a href=\"../gonggaodetail.html\?id="+temp.message.List[i].id+"\" target=\"_blank\" title="+temp.message.List[i].title+" href=\"#\"><em>"+temp.message.List[i].title+"</em></a></li>";
}
content+="</ul>";
jq("#gonggao").append(content);
}
}
}),



Request = {
QueryString : function(item){
var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&?)","i"));
return svalue ? svalue[1] : svalue;
}
}

jq = jQuery.noConflict();
jq(document).ready(function()
{
alert(Request.QueryString('id'));
})




代码贴出来了,大家帮我看看,这样传参后,为什么是“null”呢,地址栏是对的呀:http://localhost:5965/netShop/gonggaodetail.html?id=3

这是为什么呀?
...全文
630 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qingyingfei 2012-10-16
  • 打赏
  • 举报
回复
谢谢大侠!!网上找的Request居然忽悠我……[Quote=引用 1 楼 的回复:]
JScript code
//var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&?)", "i"));
var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]……
[/Quote]
Go 旅城通票 2012-10-16
  • 打赏
  • 举报
回复
//var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&?)", "i"));
var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&)?", "i"));//最后的?放出()来

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧