Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

$_GET data using javascript

function $_GET(q,s) {
    s = (s) ? s : window.location.search;
    var re = new RegExp('&'+q+'=([^&]*)','i');
    return (s=s.replace(/^?/,'&').match(re)) ?s=s[1] :s='';
}

console.log($_GET("myvariable"));
Comment

$_GET data using javascript


function parseURLParams(url) {
    var queryStart = url.indexOf("?") + 1,
        queryEnd   = url.indexOf("#") + 1 || url.length + 1,
        query = url.slice(queryStart, queryEnd - 1),
        pairs = query.replace(/+/g, " ").split("&"),
        parms = {}, i, n, v, nv;

    if (query === url || query === "") return;

    for (i = 0; i < pairs.length; i++) {
        nv = pairs[i].split("=", 2);
        n = decodeURIComponent(nv[0]);
        v = decodeURIComponent(nv[1]);

        if (!parms.hasOwnProperty(n)) parms[n] = [];
        parms[n].push(nv.length === 2 ? v : null);
    }
    return parms;
}

Comment

PREVIOUS NEXT
Code Example
Javascript :: remove all white spaces and different characters globally 
Javascript :: javascript target closest id 
Javascript :: how to change css using javascript 
Javascript :: override backswipe behaviour in ios and android react native 
Javascript :: agrgar atributo con id jquey 
Javascript :: react axios fetchData with loading screen plus API 
Javascript :: How to concatenate two textbox values in JavaScript 
Javascript :: Authomatically set an environment variable from response in postman 
Javascript :: how sum all array element with while loop 
Javascript :: javascript max characters string function 
Javascript :: nodemon 
Javascript :: js contains 
Javascript :: javascript null Conversion to Number 
Javascript :: Turn array items to matrix javascript 
Javascript :: json schema bsp 
Javascript :: javaScript setMonth() Method 
Javascript :: get two types of date formate datepicker 
Javascript :: loop through elements by name js 
Javascript :: get last element of array javascript 
Javascript :: formdata is empty after append in angular 
Javascript :: how to add author to javascript 
Javascript :: adding hbs partials in express.js 
Javascript :: how to make a bar graph in JS 
Javascript :: socket ERR_CONNECTION_REFUSED 
Javascript :: cross origin http://localhost forbidden jest 
Javascript :: ag grid angular examples 
Javascript :: data-parsley-errors-container 
Javascript :: get field type file js and loop 
Javascript :: key value pair array in javascript 
Javascript :: rating calculator formula javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =