검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요 정보
검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요
본문
아래 소스는 검색되면 자동으로 페이지로 넘어 가는데 검색 버튼 만들어서 버튼 클릭 하면 넘어가게 만들려고 하는데 도와 주세요
<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 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>
<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>
<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');
location.href = 'http://www.naver.com'; // 네이버로 이동 합니다.
대신 아래로 교체 해보세요
window.open('http://www.naver.com', '_blank');
검색하기 질답글