Get URL Variables Using JavaScript

This tutorial will explain how to get URL variables using JavaScript. This will help you when you want to do some operation based on the URL variables.

Get URL Variables Using JavaScript

Use the below JavaScript code to print the URL variable. You can use the getQueryVariable() function in your JavaScript to get the variable data from URL. You only need to pass the variable as parameter in getQueryVariable() function.

If your website URL like this http://www.your-site-url.com/example.php?user_data=128

Calling getQueryVariable(“user_data”); // it would return the 128

Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool JavaScript tutorials.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: , , , ,