두가지 질문. input 및 페이지 이동~ 정보
두가지 질문. input 및 페이지 이동~
본문
input type=text 중~
input 박스에 www.sir.co.kr 입력후 확인 버튼을 누르면 새창이 열리려면 어떻게 해야 되나요?
또다른 질문은...
ie 에서는 아래처럼 하면 현재창에서 이동하는데...
top.location.href
다른 브라우저에서는 새창으로 뜨나요?
주말, 점심식사 맛있게 드세요. ^ ^
댓글 전체
1번째 질문내용에 대한 소스
----------------------------------------
<head>
</head>
<script language="javascript">
function aa(){
val=document.form1.textfield.value;
if(val.substr(0,7)=="http://"){
window.open(val,"new","menubar=yes,toolbar=yes,location=yes,width=500,height=500,top=100,left=100,scrollbars=1,resizable=1");
}else{
window.open("http://"+val,"new","menubar=yes,toolbar=yes,location=yes,width=500,height=500,top=100,left=100,scrollbars=1,resizable=1");
}
}
</script>
<body>
<form id="form1" name="form1" method="post" action="javascript:aa();">
<input type="text" name="textfield" id="textfield">
<input type="submit" name="Submit" value="sumbit">
</form>
</body>
</html>
폼에 텍스트 필드 하나 만들어서 입력한 값대로 새창 열어 주도록 했습니다. 새창크기는 스크립트 안에서 조정하시구요. 가만히 타이핑 하다 보니 http가 들어갈때가 생기겠더군요.. 한줄 더 넣었습니다..
2번째 내용은 무슨말씀인지 모르겠어요..
자바스크립트가 지원되는 브라우저에서는 동일한 결과를 보일텐데 말이죠..
저 같은 경우는 document.location.href ="http://sir.co.kr";이런식으로 씁니다..
----------------------------------------
<head>
</head>
<script language="javascript">
function aa(){
val=document.form1.textfield.value;
if(val.substr(0,7)=="http://"){
window.open(val,"new","menubar=yes,toolbar=yes,location=yes,width=500,height=500,top=100,left=100,scrollbars=1,resizable=1");
}else{
window.open("http://"+val,"new","menubar=yes,toolbar=yes,location=yes,width=500,height=500,top=100,left=100,scrollbars=1,resizable=1");
}
}
</script>
<body>
<form id="form1" name="form1" method="post" action="javascript:aa();">
<input type="text" name="textfield" id="textfield">
<input type="submit" name="Submit" value="sumbit">
</form>
</body>
</html>
폼에 텍스트 필드 하나 만들어서 입력한 값대로 새창 열어 주도록 했습니다. 새창크기는 스크립트 안에서 조정하시구요. 가만히 타이핑 하다 보니 http가 들어갈때가 생기겠더군요.. 한줄 더 넣었습니다..
2번째 내용은 무슨말씀인지 모르겠어요..
자바스크립트가 지원되는 브라우저에서는 동일한 결과를 보일텐데 말이죠..
저 같은 경우는 document.location.href ="http://sir.co.kr";이런식으로 씁니다..
너무너무 감사드려요! ^ ^