开发者

Getting Query Parameter from a URL which inturn has some URL with Query parameters

开发者 https://www.devze.com 2023-01-10 02:21 出处:网络
I\'ve the following URL http://somesite/somepage.aspx I pass a query parameter value which has another URL with query parameters like this.

I've the following URL

http://somesite/somepage.aspx

I pass a query parameter value which has another URL with query parameters like this.

http://somesite/somepage.aspx?pageURL=http://someothersite/someotherpage.aspx?param1=value&source=http://anotheronesite/anotherpage

I need to get the pageURL value as the one in the bold letters. But i'm getting

http://someothersite/someotherpage.aspx?param1=value

and i'm not getting the source param. I'm using the following JavaScript function -

  function getParameterByName( name )
  {
     name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
     var regexS = "[\\?&am开发者_开发知识库p;]"+name+"=([^&#]*)";
     var regex = new RegExp( regexS );
     var results = regex.exec( window.location.href );
     if( results == null )
       return "";
     else
       return decodeURIComponent(results[1].replace(/\+/g, " "));
  }

Any ideas?


You need to use URL encoding to encode the parameter. Otherwise & is treated as reserved character and belongs to the "base URL".


have u considered html url encoding the pageURL parameter?

this would greatly simplify your task

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号