JavaScript Know the value of GET parameters from URL

In order to know the parameters, those are passed by the “GET” method, like sometimes we pass the Email-id, Password, and other details. For that purpose, We are using the following snippet of code.
Example-1: This example get the value of “a” parameter from the URL.
html
| <h1style="color:green;">     zambiatek </h1>  <buttononclick="myGeeks()">     Click here </button>  <pid="GFG_down"style="color:green;"> </p>  <script>     function myGeeks() {         var GFG_url_string = "https://ide.zambiatek.com/login.php?a=GeeksForGeeks&b=100&c=Computer Science portal for Geeks";                 var GFG_url = new URL(GFG_url_string);         var c = GFG_url.searchParams.get("a");         var p_down = document.getElementById("GFG_down");         p_down.innerHTML = c;     } </script> | 
Output:
 
JavaScript Know the value of GET parameters from URL
Example 2:This example get the value of all the parameters from the URL.
html
| <h1style="color:green;">     zambiatek </h1>  <buttononclick="myGeeks()">     Click here </button>  <pid="GFG_down"style="color:green;"> </p>  <script>     function myGeeks() {         var GFG_url_string = "https://ide.zambiatek.com/login.php?a=GeeksForGeeks&b=100&c=Computer Science portal for Geeks";         var GFG_url = new URL(GFG_url_string);         var a = GFG_url.searchParams.get("a");         var b = GFG_url.searchParams.get("b");         var c = GFG_url.searchParams.get("c");         var p_down = document.getElementById("GFG_down");         p_down.innerHTML = a + "<br>" + b + "<br>" + c;     } </script> | 
Output:
 
JavaScript Know the value of GET parameters from URL
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!
 
				 
					


