target = "_blank" 새탭이 열렸을 때 그 새탭이 뜨자마자 닫는 방법 질문입니다.
본문
<html>
<head>
<title>연습</title>
</head>
<body>
<form name="f1" id="f1" target="_blank">
이름:<input type="text" name="subject" id="subject"/><br />
내용:<input type="text" name="content" id="content"/><br />
글쓴이:<input type="text" name="writer" id="writer"/><br />
입력:<input type="text" name="insdt" id="insdt"/><br />
<input type="submit" value="전송" id="button2" />
</form>
</body>
</html>
위의 소스코드에서 서브밋을 하면 새탭이 열리는데 그 새탭이 바로 닫히는 방법이 있나요? 알려 주시면 정말 감사하겠습니다!!
답변 2
form target를 왜 _blank로 하나요?? 뭐 여튼 ..쓰시는 이유가 있겠지요??
stackoverflow 에 나와있는겁니다.
<form name="f1" id="f1" target="위도우 이름">
이름:<input type="text" name="subject" id="subject"/><br />
내용:<input type="text" name="content" id="content"/><br />
글쓴이:<input type="text" name="writer" id="writer"/><br />
입력:<input type="text" name="insdt" id="insdt"/><br />
<input type="submit" value="전송" id="button2" />
</form>
<script>
var childWindow;
$('form').get(0).onsubmit = function () {
childWindow = window.open('', '윈도우 이름');
};
var checkWindowClose = setInterval(function () {
if (childWindow.closed) {
alert('Window is closed');
clearInterval(checkWindowClose);
} else {
try {
if (childWindow.document.URL == 'something') {
clearInterval(checkWindowClose);
}
} catch (err) {
}
}
}, 1000);
</script>
시간은 조절해서 쓰세요. 1000->을 원하는 시간으로. 아주 바로 닫을려면
<script>
var childWindow;
$('form').get(0).onsubmit = function () {
childWindow = window.open('', '윈도우 이름');
childWindow.close();
};
</script>
이거 쓰시며 될겁니다.
그누보드5라면
<?alert_close('완료되었습니다.');?>