// An <area id="myArea" href="/en-US/docs/HTMLAreaElement?q=123"> element is in the document
const area = document.getElementById("myArea");
area.search; // returns '?q=123'HTMLAreaElement: search property / notebook
HTMLAreaElement: search property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
let params = new URLSearchParams(queryString);
let q = parseInt(params.get("q"), 10); // returns the number 123