开发者

Insert iFrame and then have it load before all other content on FF

I have browser plugins that insert an iframe into a webpage. The iframe is inserted as early as possible (using DOMContentLoaded) so that the contents of the iframe will render with the page.

In Firefox that doesn't happen however. Even though the iframe seems to be inserted early, the content of the page/images/etc load prior to the iframe's content.

Is there a way around this Firefox behavior so that the iframe content can load early or first?

Not sure if it matters but here are two methods with equivalent results:

Method 1. Inserting the iframe on DOMContentLoaded

Method 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_ST开发者_运维百科ART

       try {
           //create iframe

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


The listener DOMContentLoaded fires later than one would think on FF. The problem was solved by using Firefox's onLocationChange (which fires on the URL change) with a setTimeout loop set to 50ms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜