-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurlgetty.js
36 lines (32 loc) · 1.09 KB
/
urlgetty.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* $.URLgetty() - URL parameters via GET method
*
* It is a simple jQuery plugin to get the parameters setted via GET method
*
* $.URLgetty() to initialize it
* $.URLgetty.param('name') to get a specific value of the parameters
*
* @author Miguel Gocobachi <miguelg@gocobachi.mx>
*/
if (window.jQuery) {
$(function($) {
$.URLgetty = function() {
var params = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
if (params.length > 0) {
$.URLgetty.parameters = {};
$.each(params, function(key, param) {
param = param.split('=');
$.URLgetty.parameters[param[0]] = param[1];
});
}
};
$.URLgetty.param = function(name) {
if (('undefined' === typeof name) ||
'undefined' === typeof $.URLgetty.parameters[name]) {
return null;
}
return $.URLgetty.parameters[name];
};
$.URLgetty.parameters = null;
}(jQuery));
}