Languages
[Edit]
EN

JavaScript - get search part from current URL

3 points
Created by:
Zayyan-Todd
860

In this article, we would like to show you how to get the search part from the current URL in JavaScript.

Quick solution:

var currentSearch = location.search;

 

Simple explaination

When we call location.search property it returns search part from currenly typed URL in the web browser address bar.

location.search usage example in JavaScript.
location.search usage example in JavaScript.

 

References

  1. Query string - Wikipedia

Alternative titles

  1. JavaScript - get query part from current URL
  2. JavaScript - get query string from current URL
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join