<html>
<head>
<title>完美关闭</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><script>
function doexit()
{
if (document.all.hid.value!="1"){
window.open("http")
}
}
function gob(){
if (document.all.hid.value=="1"){
return;
}else{
return "非正常关闭";
}
}
</script>
<body onbeforeunload="return gob()" onUnload="doexit()">
<form name="form1" method="post" action="">
  <p> 
    <input type="text" name="textfield">
    <input name="hid" type="hidden" id="hid">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit" onClick="document.all.hid.value='1'">
  </p>
</form>
</body>
</html>