-5

I've searched all over the place, but I can't find a one post that gets a query string value in a single line, without writing a function themselves...

Isn't getting a value from a query string built into JQuery?

NomenNescio
  • 2,899
  • 8
  • 44
  • 82
  • 4
    Hu... What ?... Can you explain with some little code what you want ? – Denys Séguret Nov 14 '12 at 20:06
  • No, getting query strings from the browser is not something that's built into jquery, see http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values – Sean Airey Nov 14 '12 at 20:07
  • I think this might help you or at least get you started: http://stackoverflow.com/questions/647259/javascript-query-string – iMoses Nov 14 '12 at 20:08
  • 3
    Why does it have to be a single line? That's an odd requirement. – jrummell Nov 14 '12 at 20:08

2 Answers2

2

Us regular expression to search key and then it corresponding value. jsfiddle

var value = location.search.match(new RegExp(key + "=(.*?)($|\&)", "i"))[1];
Anoop
  • 23,044
  • 10
  • 62
  • 76
0

start with window.location.href, then use string commands to substring at first '?'.

Ben Barden
  • 2,001
  • 2
  • 20
  • 28