Thursday, 27 April 2017

php - Mimic $_GET in Javascript

You need to get the URL parameters I'd suggest using a regular expression and/or jQuery, a quick example:




$.getUrlParameters = function(name, url) {
var theURL = url || window.location.href;
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(theURL);
if (!results) { return 0; }
return results[1] || 0;
}


See this similar topic:
How can I get query string values in JavaScript?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...