How can I get query string values in JavaScript?

Ads

 
 

Share on Google+Share on Google+

Java Coder
How can I get query string values in JavaScript?
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

How can I get query string values in JavaScript?

Ads
View Answers

December 27, 2013 at 5:44 PM


To get a query string value, you can use JQuery and JavaScript.. here is the code:

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, " "));
}

Ads









Related Tutorials/Questions & Answers:
Advertisements

Ads

 
Advertisement null

Ads