Skip to content
/ GET.js Public

Get the data passed to the current page via the URL parameters like in PHP

License

Notifications You must be signed in to change notification settings

m-r-r/GET.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GET.js

GET.js helps to retreive the data passed in a URL query string.

It can be used in a browser or in Node.js

Installation

Just download the script and include it in your page, like this:

<script type='text/javascript' src='GET.js'></script>

There is also a minified version:

<script type='text/javascript' src='GET.min.js'></script>

GET.js can also be used in node.js and is available through the npm:

npm install GET.js

Usage

If you use GET.js in a Web browser, you can access the data in the query string of the current page through the $_GET array:

console.log(document.location.href); // foo.html?bar=baz&hello=world
console.log($_GET['bar']); // baz
console.log($_GET['hello']); // world

You can also use the parse_query function to parse the query string of another URL:

var url = 'http://foo.bar/?a=1&b=2&c=3';
console.log(parse_query(url)); // {a: 1, b: 2, c: 3}

If you have installed GET.js through the npm, you can use it in node.js like this:

var GETjs = require('GET.js');  // import it first

var url = 'http://foo.bar/?a=1&b=2&c=3';
GETjs.parse_query(url); // {a: 1, b: 2, c: 3} // Use it as in the browser

Licence

GET.js is licenced under the BSD 3-clauses license, see the COPYING file for details ...

Have fun !

About

Get the data passed to the current page via the URL parameters like in PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published