I have URL like :
http://domain/catergory/Education?max-post=5/
How can I get Education from that URL. Education is in between "/" and "?".
Thanks for your help.
You can use a regexp for it:
var url = 'http://domain/catergory/Education?max-post=5/';
var val = url.match(/\/([^\/\?]*)\?/)[1];
To understand the regexp you can use this site: http://regex101.com/r/aQ3yF1#javascript
function getQuery(key) {
var queryStr = location.search.match(new RegExp(key + "=(.*?)($|\&)", "i"));
if (!queryStr)
return
return queryStr[1];
}
var id = getQuery('id');
var comment = getQuery('comment');
splitmethod (developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…)