프로그래밍
window.close 문제 해결
GOHA
2012. 5. 2. 17:16
728x90
크롬에서 같은 소스에 같은 구글 커넥션을 맺는데 window.close가 안 먹힐 때가 있다.
이건 크롬 버그 같은데 다음과 같이 해결하면 된다.
window.open('','_self');
window.close();
이렇게 써줘야 한다.
ex)
1)
function closeMe(){
var win=window.open("","_self");
win.close();
}
2)
<a href="javascript:window.open('','_parent','');window.close();">
Close this window</a>
=============================================================
다른 예
function windowClose()
{
if (/MSIE/.test(navigator.userAgent))
{
//Explorer 8이상일때
if(navigator.appVersion.indexOf("MSIE 8.0")>=0)
{
window.opener='Self';
window.open('','_parent','');
window.close();
}
//Explorer 7이상일때
else if(navigator.appVersion.indexOf("MSIE 7.0")>=0)
{
window.open('about:blank','_self').close();
}
//Explorer 7미만일때
else
{
window.opener = self;
self.close();
}
}
}
728x90