Blog Sections Open
Reading URL Query Parameters with JavaScript
A small JavaScript helper for extracting query-string values when frontend behavior depends on GET parameters.
Sometimes the frontend only needs one small helper: read a query parameter and adjust behavior on the page without a server round-trip.
This short note shared a compact JavaScript function for extracting GET parameters from the current URL.
Example URL
http://example.com/index.php?id=123&page=home
Example usage
var id = getUrlVars()["id"];
var page = getUrlVars()["page"];
alert(id);
alert(page);
Helper function
function getUrlVars() {
var vars = {};
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
vars[key] = value;
});
return vars;
}
It is a tiny utility, but the principle remains useful in landing pages, filter UIs, search forms, and tracking scenarios where a little client-side state comes through the URL.
A Starter Boilerplate for Building MODX Evolution Modules
A reusable module skeleton for Evolution CMS projects with separated model, controller, and view layers plus editable configuration.
Tracking Resource Views with a TV and Plugin in Evolution CMS
A classic page-hit counter pattern for Evolution CMS using a text TV, an OnLoadWebDocument plugin, and optional listing integration.