Thursday, January 29, 2026
HomeLanguagesJavascriptHTML DOM URL searchParams property

HTML DOM URL searchParams property

The searchParams property returns a URLSearchParams object allowing access to the GET all the decoded query arguments contained in the URL.

Syntax:

params = url.searchParams;

Return Value: A URLSearchParams object.

Example: In this example, we will get the searchParams of the URL, here URL is “https://gfg.com/?name=Taran” taken for example.

In this URL we will get the name parameter using this property.




<!doctype html>
<html>
<head>
    <meta charset="utf-8">
<title>HTML DOM URL searchParams property</title>    
</head>
<body>
    <h1>neveropen</h1>
    <p>Click Here To Get searchparams</p>
    <button onclick="Check()">Click Here</button>
    <div class="child"></div>
</body>
<script>
    function Check(){
         let params = (new URL(
            "https://gfg.com/?name=Taran")).searchParams;
                console.log(params);
                console.log(
      "Name parameter from URL is :", params.get("name"));
        }
</script>
</html>


Output:

Before Button Click:

After Button Click:

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6848 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6916 POSTS0 COMMENTS