옛날에 만들어둔거긴 한데, 공유할까해서 공유해봅니다.
License: WTFPL
1 2 3 4 5 6 7 8 9 | window.queryString = function () { var QueryObject = {}; var k = window.location.search; const params = k.substring(1,k.length).split( "&" ); for ( var i = 0; i < params.length; i++) { QueryObject[params[i].split( "=" )[0]] = params[i].split( "=" )[1]; }; return QueryObject; } |
Module 호환 (이건 방금만든거)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ! function (e,n) { "object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" == typeof define && define.amd ? define(n) : (e = e || self, function () { var t = e.queryString , o = e.queryString = n(); }()) }( this , function () { "use strict" ; function e() { if ( typeof window != "undefined" ) { var t = {}; var o = n(window.location.search); for ( var i = 0; i < o.length; i++) { var c = o[i].split( "=" ); t[c[0]] = c[1]; }; return t; } } function n(e) { return e.substring(1,e.length).split( "&" ); } return e; }) |