Get parameter from URL JavaScript | Example code

  • by

JavaScript itself has nothing built-in for handling query string parameters. Code running in the latest browser can use the URL object (which is part of the APIs provided by browsers to JS).

Get parameter from URL JavaScript Example code

HTML example code


		var url_string = ""; 

		var url = new URL(url_string);
		var c = url.searchParams.get("c");



Get parameter from URL JavaScript

Get parameter from the actual URL JavaScript

You can get the query string from the URL of the current page with:

const urlParams = new URLSearchParams(;
const pageSize = urlParams.get('pageSize');

Output: 25

Do comment if you have any doubts and suggestions on this JS URL topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.