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中写数据库的操作。
<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中写数据库的操作。
第一个解决方案不错,但第二个关闭窗口的不太明白,因为没接触过,可能会花时间去了解,但有别的办法吗?
function window.onbeforeunload() {
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
alert("关闭时的操作");
return false;
}else {
alert("你在刷新")
}
}问题三 所有的html标记都具有onclick事件
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位置插的不对吧,请指教,我也是查查资料!
谢谢大家!