我有一个 onload 事件,它检测 iFrame 是否已完成加载。它在 FF 中运行良好,但在 Chrome 或 IE 中没有任何想法?
<html>
<head>
<title>Iframe onload event</title>
<link rel="stylesheet" type="text/css" href="../../ext-4.2.0-beta/resources/css/ext-all.css">
<script type="text/javascript" src="../../ext-4.2.0-beta/ext-all-debug.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function(){
//create a button
Ext.create('Ext.button.Button',{
text: 'Open Iframe',
handler: function(){
//try to get a reference to an already existing iframe
var dlIframe = Ext.get('CSMREP_DOWNLOAD_IFRAME');
//destroy the iframe if already exists
if(dlIframe){
dlIframe.destroy();
}
var mask = Ext.getBody().mask('iframe loading...');
//add an iframe to download the report
var iframe = Ext.DomHelper.append(Ext.getBody(),
'<iframe id="CSMREP_DOWNLOAD_IFRAME" src="iframe.php" style="display:none;"></iframe>');
iframe.onload = function(){
Ext.getBody().unmask();
};
},
renderTo: Ext.getBody()
});
});
</script>
</body>
</html>