1.onclick后在一个隐藏的iframe里打开php程序
<input type="button" onclick="window.frames['db'].location.href='db.php'"/>
<iframe style="width:0;height:0" name="db"/>然后在db.php里写要进行的数据库操作2. 可使用XMLHTTP来实现 
<body onunload="checkDB()">
<script type="text/javascript">
function checkDB(){
if(event.clientX>document.body.clientWidth && event.clientY<0||event.altKey)
{
    xml = new ActiveXObject("Msxml2.XMLHTTP");
    xml.open( "get", "execSql.php", false );
    xml.send();
}
</script>然后在execSql.php中写数据库的操作。

解决方案 »

  1.   

    谢谢ice_berg16!
    第一个解决方案不错,但第二个关闭窗口的不太明白,因为没接触过,可能会花时间去了解,但有别的办法吗?
      

  2.   

    问题二 修改以下代码来完成你的要求
    function window.onbeforeunload() {
      if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
      {
        alert("关闭时的操作");
        return false;
      }else {
        alert("你在刷新")
      }
    }问题三 所有的html标记都具有onclick事件
      

  3.   

    问题二的解决方案是写在javascript里吧,当关闭窗口的时候触发,那么可以采用第一个问题的解决方法来处理吧!我试一下!
      

  4.   

    <script language="javascript">
    function window.onbeforeunload() {
      if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
     {   window.frames['db'].location.href='db.php'";
        return false;
      }else {
        alert("你在刷新");
      }
    }
    </script>
    <html><frameset name="frames1" cols="80%,*">
       
      <frameset name="frames2" rows="12%,65%,*">
      <frame src="php25.php" name="frame4">
      <frame src="words.php" name="frame1">
      <frame src="AddRecord.php" name="frame2">
      </frameset>
     <frame  name="frame3" src="list.php">
    </frameset>
    <noframe>
    <body>
    <iframe style="width:110;height:110" name="db">
    </body>
    </noframe>
    </html>
    这样试了一下,效果没出来,应该是我的iframe位置插的不对吧,请指教,我也是查查资料!
    谢谢大家!
      

  5.   

    用xmlhttp不行,大概没有引用或者php不支持,不清楚,我试图在按关闭的时候掉个隐藏的iframe失败!