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 = "[\\?&]"+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?
2 Answers 2
You need to use URL encoding to encode the parameter. Otherwise &
is treated as reserved character and belongs to the "base URL".
Comments
have u considered (削除) html (削除ここまで) url encoding the pageURL parameter?
this would greatly simplify your task
C#
but maybe this helps you: stackoverflow.com/questions/1380617/request-url-parameter Anyway, you have to encode the&
so that it is not recognized as parameter of the "base URL".