Get Parameter Value from URL

Hi Experts,

I need to get the value of a parameter in the URL.

I simply want the value of "clear".  How can I get this in Javascript??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi jollykh,

It might sound bad but here was the first link off of a google search:

function getQueryVariable(variable) {
  var query =;
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
  alert('Query Variable ' + variable + ' not found');

You would do this to get clear

  alert( getQueryVariable("clear") );

Joe P

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jollykhAuthor Commented:
I saw that but that code doesn't work.  I tested it out and I didn't get back my value.  I just recieved an alert box that said Query Variable clear not found.
Hi BogoJoker,

try this.

function GetParamValue(param)    {
    var url = document.URL;
    var val = url.replace(eval("/.+\?.*"+param+"=([^&]*)/"), "$1");
<form name="form1" method="post" action="test2.asp">
  <table width="100%"  border="0">
      <td><input type="button" name="Button" value="GetParameter" onClick="GetParamValue('clear')"></td>

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

hi jollykh,

BogoJoker's code should work. can you show us your code?
ZvonkoSystems architectCommented:
My method is this:

function getParam(theKey){
  var qV ="[?&]"+theKey+"="));
    return unescape((qV[1]+"&").split("&")[0]);

var clearVal = getParam("clear");

jollykhAuthor Commented:
I need to apologize to everyone.  I failed to mention that this is happening within a frame.  Everyone's code that I tried worked so I'm going to split the points.  Hope you are ok with this.
You wanted to split the points but it looks like that wasnt the result =)
You can reopen the question by posting in Community Support, make sure you tell them this Question is: Q_21827485
Split Points is a link down at the bottom by the comment text box.  Hope everyone gets their share of the points if you indeed wanted to split the points.

Joe P
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.