onload函数在iFrame中不起作用

问题描述:

我有一个onload事件,它检测iFrame是否已完成加载。它在FF中正常工作,但在Chrome或IE中没有任何想法?onload函数在iFrame中不起作用

<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> 

为什么你不这样做:http://ext4all.com/post/detect-iframe-load-event?这样你就可以使用ExtJS监听器。

+0

我会测试一下谢谢:) – Kal 2013-03-02 10:13:56