Click here to Skip to main content
15,891,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi How to get query string value in jquery in html page open,

Note: no need in server side code,need in client side code in html page using document.ready function.

i will pass query sting like this Welcome.html?Username=aaaa

Regards

Aravind
Posted

1 solution

You don't need jQuery for that purpose. You can use just some pure JavaScript:
XML
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, " "));
}

var prodId = getParameterByName('prodId');
 
Share this answer
 
Comments
Aravindba 14-Oct-14 7:37am    
how u call this function ? in function.ready ? can u explain ? u declare variable prodid,but where u put this code ? inside script tag ? or any other load event ?
Note: i need form page open time,may be document.getready function.can u pls give where to call this variable code ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900