New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home JavaScript JavaScript Get URL and URL Parameters

JavaScript Get URL and URL Parameters

JavaScript Get URL and URL Parameters

Welcome back to, in this post we will see how get URL and URL parameters with the help of JavaScript functionality. People also asked how to Get the values from the “GET” parameters (JavaScript),
Most of the time we need to fetch the parameters from URL.


so here we are taking a URL with having some parameters and will separate the param from the URL with some pre defined JavaScript functions.
JavaScript can access the current URL in parts. For this Link:
window.location.protocol = "http:"" = ""
window.location.pathname = "/tool/f.php" = "?id=63"

So to get the full Website address path in JavaScript:

var newURL = window.location.protocol + "//" + + "/" + window.location.pathname +;

If you need to break up up the pathname, for example, a full website address like http://localhost/wordpress/blah/blah/blah/index.php, you can split the string on “/” characters.

var pathArray = window.location.pathname.split('/');

Then access the different parts by the parts of the array, like

var secondLevelLocation = pathArray[0];

To put that pathname back together, you can stitch together the array and put the “/” back in:

var newPathname = "";
for (i = 0; i < pathArray.length; i++) {
  newPathname += "/";
  newPathname += pathArray[i];

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error

How to integrate Razorpay Payment Gateway using PHP.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript