Javascript Get Variable Value From Browser Url Using Get Method
- Forums
- Javascipt
- Javascript Get Variable Value From Browser Url Using Get Method
learn how to get variable value from browser address url using javascript programming code [841], Last Updated: Sat May 18, 2024
setelr
Sun Dec 18, 2011
2 Comments
650 Visits
can someone please help me, i am used to using php on my forms. depending on what method i use whether it is POST or GET i can always get the variable on a submitted form.
but for javascript, how do i get the variable value from the url on the browser.
lets say i have a url that looks like this: http://www.example.com/index.php?user_id=23&name=John
ok, as you can see i have to variables
user_id=23
name=John
with PHP, all i have to do is display the variable using simple code like this:
<?php
echo $_GET['name'];
?>
OUTPUT: John
ok, now how do you do this with javascript?