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
Post a Comment