2009/07/24
2009/06/14
jsp에서 한글로된 파라미터값을 GET방식으로 보내기..(URL encoding)
한글로 된 파라미터값을 get방식으로 보내다가 에러가 나는 경우가 있습니다.
원인은 URL encoding을 안해주어서 그렇더군요 브라우져마다 처리하는 방식이 다르다나…
암튼 이 문제를 처리하는 방식은 컨테이너에서 설정하는 방법이 있고 아에 값을 보낼 때 encoding 을 하여 보내는 방법이 있습니다…
구글을 해매다가 찾은 것입니다… javascript를 이용한 방법입니다..~~ 참고해 주세요.
저는 그냥 파라미터 값을 스크립트로 받아와서 처리하여 바로 전송하는 방법을 사용했지만 방법은 여러가지가 있겠지요…
아~~ 고수의 길은 멀고도 멀다는 생각이 듭니다..ㅋ
<script type=”text/javascript”>
function encodeURL(email, userName){
var s0, i, s, u;
s0 = “”; // encoded str
for (i = 0; i < userName.length; i++){ // scan the source
s = userName.charAt(i);
u = userName.charCodeAt(i); // get unicode of the char
if (s == ” “){s0 += “+”;} // SP should be converted to “+”
else {
if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0×30) && (u <= 0×39)) || ((u >= 0×41) && (u <= 0x5a)) || ((u >= 0×61) && (u <= 0x7a)))
{ // check for escape
s0 = s0 + s; // don’t escape
}
else { // escape
if ((u >= 0×0) && (u <= 0x7f)){ // single byte format
s = “0″+u.toString(16);
s0 += “%”+ s.substr(s.length-2);
}
else if (u > 0x1fffff){ // quaternary byte format (extended)
s0 += “%” + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
s0 += “%” + (0×80 + ((u & 0x3f000) >> 12)).toString(16);
s0 += “%” + (0×80 + ((u & 0xfc0) >> 6)).toString(16);
s0 += “%” + (0×80 + (u & 0x3f)).toString(16);
}
else if (u > 0x7ff){ // triple byte format
s0 += “%” + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
s0 += “%” + (0×80 + ((u & 0xfc0) >> 6)).toString(16);
s0 += “%” + (0×80 + (u & 0x3f)).toString(16);
}
else { // double byte format
s0 += “%” + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
s0 += “%” + (0×80 + (u & 0x3f)).toString(16);
}
}
}
}
location.href=”forumContent.htm?email=” + email + “&userName=” + s0;
return s0;
}
</script>
2009/06/12
TinyMCE 웹에디터와 submit
TinyMCE Editor의 null에대한 유효성 체크
구글링을 통해.. 찾아낸 방법을 소개한다.
TinyMCE Editor는 submit하기 전에 tinyMCE.triggerSave();를 실행하여 textarea에 값을 바인드 시켜주어야 한다.
아래는 간단하게 에디터의 생성과 유효성체크에 대한 코드를 적어놓는다.
에디터 생성
tinyMCE.init({
// General options
id : “content1″,
mode : “textareas”,
theme : “advanced”,
language : ‘ko’,
// Theme options
theme_advanced_buttons1 : “bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect”,
theme_advanced_buttons2 : “”,
theme_advanced_toolbar_location : “top”,
theme_advanced_toolbar_align : “left”,
theme_advanced_resizing : true
});
유효성체크
function check_CT_AA(frm){
tinyMCE.triggerSave();
if(frm.title.value == ” || frm.title.value == null){
alert(‘제목을 입력하세요.’);
frm.title.focus();
}
else if(trim(frm.content.value) == ”){
alert(‘내용을 입력하세요.’);
}
else{return true;}
return false;
}
2009/05/04
input(text)에서 ENTER시에 자동으로 submit되는 문제??
ittn 사이트 에서 게시판 중 페이지 네이게이션 개발시에 발생한 현상!!
구글링을 통해 많은 개발자들이 격었던 문제 였던 듯….ㅎㅎ 초보 개발자인 나는 ….ㅋ
<input type=”text” class=”inputText” id=”directPageValue” value=”" onkeypress=”return enterCheck(event);”/>
function enterCheck(e){
if(e.keyCode == 13){
return false;
}
else{
return true;
}
}
이렇게 스크립트를 하나 추가 하니 submit되는 문제를 막을 수 있었다…
하지만 스크립트를 끄로 FF에서 확인 시 제어가 안되어
꼼수 작렬…ㅋㅋ <input type=”text” style=”display: none;”> 이렇게 너어 주니 되네…