1

주제: 검색창 버그

<input type="text" name="search" value="" onkeypress="if (event.keyCode == 13) { try{window.location.href='/search/' + document.getElementsByName('search')[0].value.replace('%', '%25'); return false;}catch(e){} }" class="sinput" />

현재 검색창은 저렇게 되어있는데 아래와 같이 수정하는게 맞을거 같습니다.

<input type="text" name="search" value="" onkeypress="if (event.keyCode == 13) { try{window.location.href='/search/' + this.value.replace('%', '%25'); return false;}catch(e){} }" class="sinput" />

아시겠지만 name 속성의 값은 중복이 되어도 상관이 없기때문에
저 코드가 나오기 전에 이미 name="search" 를 쓴 경우 검색이 안되는 일이 발생합니다.
게다가 getElementsByName을 사용하는 것보다 this를 사용하는게 더 자바스크립트 다운것 같고요. smile

2

답글: 검색창 버그

음 잘 몰라서 여쭈어봅니다 smile
getElementsByName 은 모든 브라우저에서 호환되는데, this. 속성은 어떤가요?

어디에선가 (아마 W3C 권고안이었던듯?) 최대한 this. 속성을 쓰는 것을 자제하라는 글을 본 적이 있어서요^^;

"Everything looks different on the other side."

-Ian Malcomm, from Michael Crichton's 'The Jurassic Park'

3

답글: 검색창 버그

inureyes 작성:

음 잘 몰라서 여쭈어봅니다 smile
getElementsByName 은 모든 브라우저에서 호환되는데, this. 속성은 어떤가요?

어디에선가 (아마 W3C 권고안이었던듯?) 최대한 this. 속성을 쓰는 것을 자제하라는 글을 본 적이 있어서요^^;

헛 W3C에 그런 내용이 있었나요?;;
근데 this를 못쓰게된다면 자바스크립트를 사용하는데 상당한 애로사항이 있을거 같네요.;
좀 찾아봐야겠네요. smile

일단 제가 알고 있는 브라우저에서는 다되긴 합니다.(몇 개 되지도 않지만요;; )


음.. 도저히 못찾겠네요. OTL
혹시 어디있는지 아시면 저에게도 알려주세요. 흑;;

Peris (2006-04-14 23:48:29)에 의해 마지막으로 수정