在我的onbeforeunload
函数中,我们正在自动断开ActiveX控件与服务器的连接。
这个过程大约需要3到4秒(我们无法控制),所以我想显示一条消息让用户知道,只要控件断开,它们的刷新/导航离开/关闭窗口就会发生。我不想弹出一个alert()
,只想给用户显示“异步”消息。onbeforeunload - 无法更改页面UI
但是,我似乎无法对onbeforeunload
内页面的UI进行任何更改。我不能使用我已经拥有的吐司消息类,或者甚至改变“状态”div
,因为他们似乎没有做任何事情。
这是onbeforeunload
函数的限制吗?我唯一的选择是使用alert()
?
编辑
代码例如:
function handleWindowOnBeforeUnload() {
//alert('Disconnecting from client...'); //Would rather not use an alert()
ShowToast('Closing connection...'); //Doesn't show
$('#statusDiv').html('Auto-disconnect...'); //Neither does this
//This is what takes ~4 seconds
acx.stopConnection();
}
代码示例会有帮助 – Christian 2013-02-13 17:32:41