ASP.Net中OnBeforeUnLoad事件中调用__doPostBack不起作用?
我想当页面离开时,调用__doPostBack,但是服务器端总是得不到PostBack通知。
但感觉处理地不专业,
感觉像__doPostBack用一个线程,onbeforeunload用另外一个线程。如果让__doPostBack先完成并使onbeforeunload挂起一些时间,就OK了...不知理解对不对
function test()
{
__doPostBack('Button1','');
}
{
__doPostBack('Button1','');
}
<body MS_POSITIONING="GridLayout" onbeforeunload=" test()">
但是如果在别的地方调用__doPostBack就没有问题
我再在__doPostBack后面加了一个延时,就可以了
<script >
function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
function test()
{
__doPostBack('Button1','');
pause(100);
}
</script>
function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
function test()
{
__doPostBack('Button1','');
pause(100);
}
</script>
但感觉处理地不专业,
感觉像__doPostBack用一个线程,onbeforeunload用另外一个线程。如果让__doPostBack先完成并使onbeforeunload挂起一些时间,就OK了...不知理解对不对