Classified Sites List Classified Sites List List of Making Back-links

1. Australia Classified Sites

2. Canada Classified List

3. UK Classified Sites

4. USA Classified Sites List

1. UAE Classified Sites List

2. Indian Classified Sites List

3. Pakistani Classified Sites List

4. Bangladeshi Classified Sites List

1. High PR Do-follow Guest Posting Sites list

2. 20 High PR Social Networking Site List 2016

3. PR-5 Do Follow Social Bookmarking Site list 2016

4. Do-follow Social Bookmarking Website list 2016

5. 100 High Page Rank Do-follow Social Bookmarking lists 2016

6. Directories Submission Sites List

7. Articles Submission Sites List

How I get query string values in JavaScript?

Today i am going to show you, how you can get string values by using JavaScript ?. Yes you can do it by using pure JavaScript, you do not need any JavaScript Plugin or library for this task. JavaScript have some build-in method for getting query string values. Here is the code of JavaScript by following this you can easily handle query values in JavaScript.

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, “\\$&”);
    var regex = new RegExp(“[?&]” + name + “(=([^&#]*)|&|#|$)”),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return ”;
    return decodeURIComponent(results[2].replace(/\+/g, ” “));

How you can use this code?

// query string: ?foo=lorem&bar=&baz
var foo = getParameterByName(‘foo’); // “lorem”
var bar = getParameterByName(‘bar’); // “” (present with empty value)
var baz = getParameterByName(‘baz’); // “” (present with no value)
var qux = getParameterByName(‘qux’); // null (absent)

You will get  the first value even there are several values are present in Url.

About Moazzam Qureshi

I am SEO expert and web developer since 2011. My hobby is to write & provides quality content about blogging, SEO , Social Media , Earn Online and Affiliate Marketing.