검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요 정보

검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요

본문

아래 소스는 검색되면 자동으로 페이지로 넘어 가는데 검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script type="text/javascript">
<!--
function enterGo() {
var obj = document.getElementById('enterLink'); // 입력창 id
  if(event.keyCode == '13') { // 엔터키 아스키 코드값
    var keyword = obj.value; // 입력된 내용
  if(keyword == '네이버') // 입력된 내용이 네이버 라면
    location.href = 'http://www.naver.com'; // 네이버로 이동 합니다.
}
}
//-->
</script>
</head>
<body>
네이버라고 입력시에만 이동 합니다.
<input type="text" id="enterLink" onKeyUp="enterGo()">
</body>
</html>
  • 복사

댓글 전체

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script type="text/javascript">
function ndSearch() {
var sValue = document.getElementById('searchline').value;
var nSearch = 'http://search.naver.com/search.naver?where=nexearch&query=';
window.open(nSearch+sValue,'');
}

</script>
</head>
<body>
<input type=text id=searchline>
<input type=button value="네이버 검색" onClick="ndSearch()">
</body>
</html>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
 <script type="text/javascript">
 <!--
 function enterGo() {
    var obj = document.getElementById('enterLink'); // 입력창 id
    var keyword = obj.value; // 입력된 내용
    if(keyword == '네이버') // 입력된 내용이 네이버 라면
      location.href = 'http://www.naver.com'; // 네이버로 이동 합니다.
    }
 }
 //-->
 </script>
 </head>
 <body>
 네이버라고 입력시에만 이동 합니다.
 <form name='frm' onsubmit="return false;">
 <input type='text' id="enterLink" onkeydown='if(event.keyCode == "13"){enterGo()};'><input type='button' onclick='enterGo();' value='검색'>
 

</form>
 
</body>
 </html>
위 코드중에
location.href = 'http://www.naver.com'; // 네이버로 이동 합니다.
대신 아래로 교체 해보세요

window.open('http://www.naver.com', '_blank');
© SIRSOFT
현재 페이지 제일 처음으로