“jQuery Obtener parámetro de URL” Código de respuesta

jQuery obtenga URL

var currentURL = $(location).attr('href'); 
var currentURL = window.location.href;
Sid Potti

Cómo obtener el parámetro URL usando jQuery o JavaScript sencillo

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');
Ankur

Obtener parámetro de 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;
};
Outstanding Ocelot

jQuery Obtener parámetro de 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"];
Brainy Butterfly

Respuestas similares a “jQuery Obtener parámetro de URL”

Preguntas similares a “jQuery Obtener parámetro de URL”

Más respuestas relacionadas con “jQuery Obtener parámetro de URL” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código