try something like<script language="javascript">
function window.onunload()
{
if (IsClosingWindowInsteadOfReloadingOrGoingToALinkOrOpeningAURLInPlace)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","DeleteDatainDatabase.asp",false);
xmlhttp.send();
}
}
</script>
function window.onunload()
{
if (IsClosingWindowInsteadOfReloadingOrGoingToALinkOrOpeningAURLInPlace)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","DeleteDatainDatabase.asp",false);
xmlhttp.send();
}
}
</script>
<script for=window event=onbeforeunload>
if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altKey)
alert("关闭窗口")
</script>
只需将上面代码放到网页中即可。
我想把alert("关闭窗口")换成location.href="aaa.asp"
即:
<script for=window event=onbeforeunload>
if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altKey)
location.href="aaa.asp"
</script>就不好用了
是不是不能重定向呀?
因为我想在关闭网页的时候删除表中的记录
应该如何实现呀?
<script for=window event=onbeforeunload>
if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altKey)
window.open("aaa.asp","delwin")
</script>其它的就在你的“aaa.asp”里面处理了。
<script for=window event=onbeforeunload>
if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altKey)
{
location.href="aaa.asp";
//不关闭窗口:
event.cancelBubble = true;
event.returnValue = false;
return false;
}
</script>
然后在aaa.asp里关闭窗口。
if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altKey)
以上条件中event.clientX > document.body.clientWidth 似乎有问题,
可改为event.clientX<0,因为关闭窗口时event.clientX和event.clientY
的值都小于0