2010-12-20 70 views
3

我有用於將iframe插入網頁的瀏覽器插件。儘早插入iframe(使用DOMContentLoaded),以便iframe的內容與頁面一起呈現。插入iFrame,然後在FF上的所有其他內容之前加載它。

然而在Firefox中並沒有發生。儘管iframe似乎早被插入,但頁面/圖像/ etc的內容在iframe的內容之前加載。

是否有解決此Firefox行爲的方法,以便iframe內容可以儘早加載或先加載?

不知道它的問題,但這裏有兩種方法具有等同結果:

方法1.插入iframe的上DOMContentLoaded

方法2:

nsiWebProgressListener() 

onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { 
    const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START; 
    const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP; 

    if (aStateFlags & STATE_STOP) { //document is undefined at STATE_START 

     try { 
      //create iframe 

     } catch (e) {} 
    } 
return true; 
}, 

回答

0

聽者DOMContentLoaded火災遲人們會想到FF。該問題已通過使用Firefox的onLocationChange(引發URL更改)並將setTimeout循環設置爲50ms來解決。