티스토리 뷰


URL 파라미터 값 읽기

/**
 * URL의 파라메터 획득.
 * @param name
 * @returns
 */
function getParam(name){
      var result = "";
      var queryString = window.location.search;
      var paramMap = {}
      if (queryString == "") result = undefined;
      if (typeof result != "undefined"){
            var params = queryString.split("?")[1];
            
            if (params == "") result = undefined;
            
            if (typeof result != "undefined") {
                  var paramObj = params.split("&");
                  for (var i=0; i<paramObj.length; i++){
                        var datas = paramObj[i].split("=");
                        paramMap[datas[0]] = datas[1];
                  }
                  result = paramMap[name];
            }
      }
      
      return result;
}
댓글
댓글쓰기 폼