javascript - How do I extract "search term" from URLs? -


how extract "test" following url?

http://www.example.com/index.php?q=test&=go

i've found script extract path (window.location.pathname), can't find or figure out how extract or split url.

-ben

var m = window.location.search.match(/q=([^&]*)/);  if (m) {      alert(m[1]); // => alerts "test" }  

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -