Link to home
Start Free TrialLog in
Avatar of R8VI
R8VI

asked on

get url parameter value in javascript

HI,

I have a URL which has the parameter "ID"

how can i get the value of the ID in javascript

please help

Thanks

R8VI
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of R8VI
R8VI

ASKER

Hi,

Thanks for this but where do I substitute the ID in your code

R8vi
wherever you're looking to use the ID value, such like this:

   var idParam = QueryString.id;

Open in new window

Avatar of R8VI

ASKER

I am sorry could you please explain a bit further
Ultimately what are you trying to accomplish with the url perameter?
Try:
var id = document.getElementById("URL").getAttribute("id");
doesn't work in Chrome...
Avatar of R8VI

ASKER

Hi,

So I have a URL like so

http://localhost:49768/Solution/IframePage.aspx?Name=Ellis&URL=http://www.test.com

I would like to get the Value of "URL" which in this case would be http://www.test.com
 and store it in a variable

Thanks

R8VI
ok, so using my example above, just create a variable:

var myURL;

then assign it like:

myURL = QueryString.URL;

the function I gave earlier runs upon page load, and it basically creates an "object" with properties that are the url parameters
You could also toggle the string with JS string functions (see http://w3schools.com/js/js_obj_string.asp) and extract the URL.