Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get parameter from url using jquery

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
    return false;
};
And this is how you can use this function assuming the URL is,
http://dummy.com/?technology=jquery&blog=jquerybyexample.

var tech = getUrlParameter('technology');
var blog = getUrlParameter('blog');
Comment

get param from url jquery

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
    return false;
};
Comment

jquery get parameter from url

 
(function($) {
    $.QueryString = (function(a) {
        if (a == "") return {};
        var b = {};
        for (var i = 0; i < a.length; ++i)
        {
            var p=a[i].split('=');
            if (p.length != 2) continue;
            b[p[0]] = decodeURIComponent(p[1].replace(/+/g, " "));
        }
        return b;
    })(window.location.search.substr(1).split('&'))
})(jQuery);
 
// Usage
var param = jQuery.QueryString["param"];
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript sort array of objects by value of key in object 
Javascript :: javascript hello world 
Javascript :: hasownproperty javascript 
Javascript :: outer click on div hide div in jqeury 
Javascript :: swift convert array to json 
Javascript :: how to get class name of element in javascript 
Javascript :: move element onclick javascript 
Javascript :: find the last occurrence of a character in a string javascript 
Javascript :: js array reverse 
Javascript :: javascript date set hours minutes seconds to 0 
Javascript :: code for javascript message box 
Javascript :: extract from a string in javascript 
Javascript :: javascript foreach arrow function 
Javascript :: javascript array.from 
Javascript :: javascript check date is greater than today 
Javascript :: how to get circle around text in react natvie 
Javascript :: javascript check if element has specific child 
Javascript :: postgres boolean column 
Javascript :: js html input limit to 5 words 
Javascript :: javascript change right click menu 
Javascript :: Self Invoking Function Simpler Syntax 
Javascript :: framer motion reactjs 
Javascript :: how to comment out code in react js 
Javascript :: get 2nd td of tr 
Javascript :: mongoose connection increase timeout in node js 
Javascript :: javascript things to remember 
Javascript :: Destructuring object from a nested object 
Javascript :: js setattribute download 
Javascript :: npm ERR! Error: connect ECONNREFUSED 
Javascript :: range in javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =