[英]Call ActionScript function when Javascript's window.onebeforeunload is called
I would like to call my function ActionScript closeApp:我想打电话给我的 function ActionScript closeApp:
public function closeAutorun(event: CairngormEvent): void {
Alert.show(
LMSModel.ERR_MESS_QUESTION,
LMSModel.ERR_MESS_TITLE,
3,
FlexGlobals.topLevelApplication as Sprite,
alertClickHandler);
}
When the user close the tab or the navigator.当用户关闭选项卡或导航器时。
Any suggestions?有什么建议么?
Thx谢谢
In actionscript, at the start of your program:在 actionscript 中,在程序开始时:
if (ExternalInterface.available) {
ExternalInterface.addCallback("closeAutorun", closeAutorun);
}
In javascript:在 javascript 中:
window.onbeforeunload = confirmClose;
function confirmClose() {
document.getElementById('app').closeAutorun();
}
where 'app' is the id of the swf instance.其中 'app' 是 swf 实例的 ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.