1. History 활용
<script type="text/javascript">
function closeWin() {
var nvua = navigator.userAgent;
if (nvua.indexOf('MSIE') >= 0){
if(nvua.indexOf('MSIE 5.0') == -1) {
top.opener = '';
}
} else if (nvua.indexOf('Gecko') >= 0){
top.name = 'CLOSE_WINDOW';
wid = window.open('','CLOSE_WINDOW');
}
top.close();
}
</script>
<a href="#" onclick="javascript:history.onclick=closeWin();">닫기</a>
창닫기
2. A 링크 활용
<a href="#" onclick="javascript:window.close();">창닫기</a>
창닫기
<a href="#" onclick="javascript:self.close();">창닫기</a>
창닫기
3. 버튼 활용
<input type="button" value="창닫기" onClick="window.close()">
<input type="button" value="창닫기" onClick="window.open('','_self').close();">
<script>
function closeMe() {
var win=window.open("","_self");
win.close();
}
</script>
<input type="button" name="Close" onclick="closeMe()" value=" 창닫기 ">
<script>
function quitBox(cmd) {
if (cmd=='quit') {
open(location, '_self').close();
}
return false;
}
</script>
<input type="button" name="Quit" id="Quit" onclick="return quitBox('quit');" value=" 창닫기 ">
4. jQuery 활용
<script src="//code.jquery.com/jquery-1.8.3.min.js"></script>
<button id="btn_close" type="button">창닫기</button>
<script>
$(function() {
$("#btn_close").on('click', function() {
self.close();
});
});
</script>
</script>