Skip to Content

get()

Get (or check) a specific query string.

JavaScript July 2, 2019

Usage

JavaScript
nebula.get(parameter, url)

Parameters

parameter
(Optional) (String) The query parameter to look for
Default: Full query string

url
(Optional) (String) The URL to parse for query parameters
Default: document.URL

Parameter Notes

If a parameter is not passed, it returns all query strings exactly like getQueryStrings().

Request or provide clarification »

Examples

JavaScript
if ( nebula.get('foo') === 'bar' ){
    //Do something if ?foo=bar is in the URL
}
JavaScript
if ( nebula.get('foo') ){
    //Do something if ?foo or ?foo=anything is in the URL
}

Demo


Visit this page with the query string ?hello (or ?hello=whatever) and open the JavaScript console to see it.

Source File

Located in /assets/js/nebula.js on line 3828.

JavaScript
nebula.get = function(parameter, url){
    var queries = nebula.getQueryStrings(url);

    if ( !parameter ){
        return queries;
    }

    return queries[parameter] || false;
};

Override

To override or disable this JavaScript function, simply redeclare it with the exact same function name.

JavaScript
nebula.get = function(parameter, url){
    //Write your own code here, leave it blank, or return false.
}