0

New in JS, How do I check if one of my querystring has a value?

Example: I have result.aspx?loc=3. How do I check this in javascript if my querystring loc has a value. I need to do this because I will use $('#target').css({'display':'none'}); to a certain div

Dumont
  • 341
  • 3
  • 9
  • 20

1 Answers1

4

try location.search

The search property returns the query portion of a URL, including the question mark (?).

and can be called like so:

<script type="text/javascript">
    document.write(location.search);
</script>

http://www.w3schools.com/jsref/prop_loc_search.asp

hunter
  • 62,308
  • 19
  • 113
  • 113