首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js获取href跳转页面传过来的参数解决思路

2012-11-09 
js获取href跳转页面传过来的参数jq.ajax({type:get,url:../ashx/indexLoad.ashx,data:m0,async:fal

js获取href跳转页面传过来的参数
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

这是为什么呀?

[解决办法]

JScript code
//var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&?)", "i"));  var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&)?", "i"));//最后的?放出()来 

热点排行