2011-01-12 3 views
1

내가 언급 한 목적을 위해 아래 코드를 시도했지만 이것은 mozila에서 작동하지 않으며 또한 확인 상자에 일부 추가 줄이 나타납니다.브라우저의 확인 상자 닫기

<html> 
<head>  
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Coordinates!</title> 
<script type="text/javascript"> 
var myclose = false; 
function ConfirmClose()   
{     
    if (event.clientY < 0) 
    {       
    event.returnValue = 'Any message you want'; 
    setTimeout('myclose=false',100); 
    myclose=true;     
}   
}   
function HandleOnClose()   
{     
if (myclose==true) 
alert("Window is closed");   
} 
</script> 


    </head> <body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()" ><a href="#">test</a> </body></html> 

mozila에 대한 의견을 제시해주세요.

+1

형식 및 철자를 수정하십시오. – Migol

답변

1

사용자가 페이지에서 벗어나려고 시도 할 때 팝업을 표시하려고하면 가능하며 크로스 브라우저 솔루션이 있습니다. 하지만, 당신이하려고하는 것은 파이어 폭스가 종료되는지 자바 스크립트에서 호출하는 것이고, 나는 자바 스크립트에서 가능하다고 생각하지 않는다. 그렇다면 다시 틀릴 수도있다.

function goodbye(e) { 
    if(!e) e = window.event; 
    //e.cancelBubble is supported by IE - this will kill the bubbling process. 
    e.cancelBubble = true; 
    e.returnValue = 'You sure you want to leave?'; 

    //e.stopPropagation works in Firefox. 
    if (e.stopPropagation) { 
     e.stopPropagation(); 
     e.preventDefault(); 
    } 
} 
window.onbeforeunload=goodbye; 

source

1

는 동일한 사용하여 jQuery를 달성 할 수있다.

체크 this 예. 텍스트 상자 닫기 창에 뭔가를 입력하십시오.