GET으로 넘어온 파라미터 가져오기
자바스크립트에서 GET방식으로 넘어온 매개변수 값들을 서버의 처리 필요없이 사용하는법을 알려드리겠습니다;;
<Script language="JavaScript">
getParameter = function(name){
search=location.search;
if(!search){
//파라미터가 하나도 없을때
document.write("에러 출력 텍스트");
return false;
}
search=search.split("?");
data=search[1].split("=");
if(search[1].indexOf(name)==(-1) || data[0]!=name){
//해당하는 파라미터가 없을때.
return "";
return;
}
if(search[1].indexOf("&")==(-1)){
//한개의 파라미터일때.
data=search[1].split("=");
return data[1];
}else{
//여러개의 파라미터 일때.
data=search[1].split("&"); //엠퍼센트로 자름.
for(i=0;i<=data.length-1;i++){
l_data=data[i].split("=");
if(l_data[0]==name){
return l_data[1];
break;
}else continue;
}
}
}
</Script>
이런식으로 작성하시고 실제 호출할때는,
<Script>
getParameter("매개변수 이름");
</Script>
으로 입력해 주시면 되겠죠.
<Script language="JavaScript">
getParameter = function(name){
search=location.search;
if(!search){
//파라미터가 하나도 없을때
document.write("에러 출력 텍스트");
return false;
}
search=search.split("?");
data=search[1].split("=");
if(search[1].indexOf(name)==(-1) || data[0]!=name){
//해당하는 파라미터가 없을때.
return "";
return;
}
if(search[1].indexOf("&")==(-1)){
//한개의 파라미터일때.
data=search[1].split("=");
return data[1];
}else{
//여러개의 파라미터 일때.
data=search[1].split("&"); //엠퍼센트로 자름.
for(i=0;i<=data.length-1;i++){
l_data=data[i].split("=");
if(l_data[0]==name){
return l_data[1];
break;
}else continue;
}
}
}
</Script>
이런식으로 작성하시고 실제 호출할때는,
<Script>
getParameter("매개변수 이름");
</Script>
으로 입력해 주시면 되겠죠.
댓글 2개
쉽다zzz
12년 전
괜찮네요
senseme
12년 전
네...ㅎㅎ감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6830 |
112211dd
|
11년 전 | 786 | |
| 6829 |
진짜다진짜가나타남
|
11년 전 | 1184 | |
| 6828 | 11년 전 | 816 | ||
| 6827 |
봉보로봉봉
|
11년 전 | 897 | |
| 6826 |
jinion
|
11년 전 | 813 | |
| 6825 | 11년 전 | 797 | ||
| 6824 |
yunkiri486
|
11년 전 | 711 | |
| 6823 |
2donggalbi
|
11년 전 | 846 | |
| 6822 | 11년 전 | 843 | ||
| 6821 | 11년 전 | 793 | ||
| 6820 | 11년 전 | 3098 | ||
| 6819 | 11년 전 | 1247 | ||
| 6818 | 11년 전 | 512 | ||
| 6817 |
|
11년 전 | 600 | |
| 6816 | 11년 전 | 2068 | ||
| 6815 | 11년 전 | 1205 | ||
| 6814 | 11년 전 | 850 | ||
| 6813 | 11년 전 | 598 | ||
| 6812 |
|
11년 전 | 977 | |
| 6811 | 11년 전 | 574 | ||
| 6810 | 11년 전 | 1533 | ||
| 6809 |
낚시가좋아
|
11년 전 | 1043 | |
| 6808 | 11년 전 | 436 | ||
| 6807 | 11년 전 | 757 | ||
| 6806 |
Unhappy
|
11년 전 | 1765 | |
| 6805 | 11년 전 | 1588 | ||
| 6804 | 11년 전 | 1111 | ||
| 6803 | 11년 전 | 549 | ||
| 6802 |
asdfg
|
11년 전 | 1129 | |
| 6801 |
아트귀농인
|
11년 전 | 497 | |
| 6800 | 11년 전 | 2550 | ||
| 6799 | 11년 전 | 1350 | ||
| 6798 | 11년 전 | 1465 | ||
| 6797 | 11년 전 | 621 | ||
| 6796 |
purple63
|
11년 전 | 420 | |
| 6795 | 11년 전 | 2627 | ||
| 6794 |
커네드커네드
|
11년 전 | 953 | |
| 6793 | 11년 전 | 397 | ||
| 6792 | 11년 전 | 2486 | ||
| 6791 | 11년 전 | 503 | ||
| 6790 | 11년 전 | 2247 | ||
| 6789 |
리아빌리티
|
11년 전 | 3088 | |
| 6788 | 11년 전 | 1338 | ||
| 6787 | 11년 전 | 669 | ||
| 6786 | 11년 전 | 385 | ||
| 6785 | 11년 전 | 714 | ||
| 6784 |
|
11년 전 | 837 | |
| 6783 | 11년 전 | 575 | ||
| 6782 | 11년 전 | 3651 | ||
| 6781 |
리아빌리티
|
11년 전 | 474 | |
| 6780 | 11년 전 | 517 | ||
| 6779 | 11년 전 | 474 | ||
| 6778 | 11년 전 | 4674 | ||
| 6777 |
바보온달123
|
11년 전 | 605 | |
| 6776 | 11년 전 | 920 | ||
| 6775 | 11년 전 | 721 | ||
| 6774 |
DANet
|
11년 전 | 628 | |
| 6773 | 11년 전 | 1557 | ||
| 6772 | 11년 전 | 1349 | ||
| 6771 | 11년 전 | 608 | ||
| 6770 | 11년 전 | 1152 | ||
| 6769 | 11년 전 | 942 | ||
| 6768 | 11년 전 | 680 | ||
| 6767 | 11년 전 | 575 | ||
| 6766 | 11년 전 | 1258 | ||
| 6765 |
크림나이트
|
11년 전 | 985 | |
| 6764 | 11년 전 | 1530 | ||
| 6763 | 11년 전 | 2589 | ||
| 6762 | 11년 전 | 521 | ||
| 6761 |
|
11년 전 | 777 | |
| 6760 |
|
11년 전 | 705 | |
| 6759 | 11년 전 | 3337 | ||
| 6758 | 11년 전 | 1004 | ||
| 6757 | 11년 전 | 1264 | ||
| 6756 | 11년 전 | 887 | ||
| 6755 |
|
11년 전 | 565 | |
| 6754 |
|
11년 전 | 707 | |
| 6753 |
|
11년 전 | 1373 | |
| 6752 | 11년 전 | 597 | ||
| 6751 |
|
11년 전 | 645 | |
| 6750 |
|
11년 전 | 2012 | |
| 6749 | 11년 전 | 1205 | ||
| 6748 |
|
11년 전 | 1108 | |
| 6747 | 11년 전 | 1154 | ||
| 6746 | 11년 전 | 826 | ||
| 6745 |
|
11년 전 | 901 | |
| 6744 | 11년 전 | 845 | ||
| 6743 | 11년 전 | 1271 | ||
| 6742 | 11년 전 | 523 | ||
| 6741 |
Abilityarch
|
11년 전 | 595 | |
| 6740 | 11년 전 | 636 | ||
| 6739 |
leewin20
|
11년 전 | 1226 | |
| 6738 | 11년 전 | 499 | ||
| 6737 | 11년 전 | 1209 | ||
| 6736 | 11년 전 | 1246 | ||
| 6735 | 11년 전 | 541 | ||
| 6734 | 11년 전 | 1275 | ||
| 6733 |
RipperTNT
|
11년 전 | 1835 | |
| 6732 |
|
11년 전 | 1333 | |
| 6731 |
|
11년 전 | 1383 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기