Reputation: 347
was trying to finish a script in jquery and I was stuck. after giving several times, I did not succeed. I need to pass the variables in the url but without using php, that is, for example:
the truth, do not know how to "capture" these values with jquery, without first going through php... thanks in advance.
Upvotes: 1
Views: 1532
Reputation: 43552
function getUrlParam(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&#]"+name+"=([^\\?&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
return results == null ? '' : results[1];
}
Pure javascript...
Upvotes: 2
Reputation:
You can catch and handle url locations with jquery and the hashchange() plugin: http://benalman.com/projects/jquery-hashchange-plugin/
Or for more advanced use with a lot of links like this, look into backbone.js url routing: http://documentcloud.github.com/backbone/#Router
Upvotes: 0