웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
input 태그에 포커스 맞추기..
2002.07.18 19:42
이걸 어떻게 설명을 해야할지 모르겠네요..^^
HTML태그중 가장 많이 사용하는 태그는 아마 Form태그라고 생각합니다.
Form태그중 input태그를 사용할시 마우스 커서를 input에다가 포커스를 해준다는 이야기가 들리더군요.
저도 확실한것이 아니라는 느낌에 확실한 100% 장담을 못듣립니다. 그냥 제가 아는 지식에서 알려드립니다.
소스는 아래와 같습니다.
<html>
<head>
<title>Focus</title>
<script language="javascript">
<!--
document.form.input.focus();
//-->
</script>
</head>
<body>
<form name="form" method="post">
<input type="text" value="" name="input" onfocus="this.blur();">
</form>
</body>
</html>
<head>와 </head>사이에 있는 스크립트는 정상이구요..^^
onfocus="this.blur();"가 있는데 이것은 실행해보니..차이가 있더군요^^
일단 첨부파일을 해놓을테니 참고하세요^^
HTML태그중 가장 많이 사용하는 태그는 아마 Form태그라고 생각합니다.
Form태그중 input태그를 사용할시 마우스 커서를 input에다가 포커스를 해준다는 이야기가 들리더군요.
저도 확실한것이 아니라는 느낌에 확실한 100% 장담을 못듣립니다. 그냥 제가 아는 지식에서 알려드립니다.
소스는 아래와 같습니다.
<html>
<head>
<title>Focus</title>
<script language="javascript">
<!--
document.form.input.focus();
//-->
</script>
</head>
<body>
<form name="form" method="post">
<input type="text" value="" name="input" onfocus="this.blur();">
</form>
</body>
</html>
<head>와 </head>사이에 있는 스크립트는 정상이구요..^^
onfocus="this.blur();"가 있는데 이것은 실행해보니..차이가 있더군요^^
일단 첨부파일을 해놓을테니 참고하세요^^
댓글 5
-
☺[폐]허접-_-
2002.07.18 20:23
-
ZipShin
2002.07.18 22:37
아주 대단하십니다.. -_-;; -
엔카일
2002.07.18 23:23
제목대로의 목적만 있다면
<body>를
<body onload="document.form.input.focus();">
로 바꾸고 헤더의 자바스크립트는 없애면 됩니다.
또 input의 this.blur();도 없애야 합니다.
this는 가급적이면 생략 안하는게 좋죠.. 되긴 되더라도 문법적으로 틀린것이니까요.. -
hooah
2002.10.13 15:43
난 왜 안되지.. ㅡ,.ㅡ;;
이건 제가 쓰는...
<html>
<head>
<title>Focus</title>
<script language='javascript'>
window.onload = focus;
function focus() {
document.form.input.focus();
}
</script>
</head>
<body>
<form name="form" method="post">
<input type="text" value="" name="input">
</form>
</body>
</html> -
GPel
2003.05.27 19:30
<html>
<head>
<title>Focus</title>
<script language="javascript">
<!--
document.form.input.focus();
//-->
</script>
</head>
<body>
<form name="form" method="post">
<input type="text" value="" name="input" onfocus="this.blur();">
</form>
</body>
</html>
-----해석-----
페이지를 읽어들이면서.. 인풋에 포커스를 맞추고..
인풋태그에서는 포커스가 맞추어지면.. 포커스를 blur해버리는;;
그러니까; 결국; 포커스는 맞추어지지 않죠;;
제목처럼의 목적이라면..
'엔카일'님의 말씀처럼;;
모순이 있는 스크립트군요^-^;
정해진 대로 this.blur(); 로 해주는것이 낳습니다;;;;
그리고 원래 소스 중
<script language="javascript">
<!--
document.form.input.focus();
//-->
</script>
이 소스는 필요가 없는;;
쿨럭;;