TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get a Query String Values in JavaScript
Anu V
Jan 25
2016
Code
959
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
function
getParameterByName(name) {
name = name.replace(/[\[]/,
"\\["
).replace(/[\]]/,
"\\]"
);
var
regex =
new
RegExp(
"[\\?&]"
+ name +
"=([^]*)"
),
results = regex.exec(location.search);
return
results ===
null
?
""
: decodeURIComponent(results[1].replace(/\+/g,
" "
));
}
Usage:
var
prodId = getParameterByName(
'prodId'
);
query string values
JavaScript