Back button causes iFrame to delay window.onLoad event

Posted by JoJo on Stack Overflow See other posts from Stack Overflow or by JoJo
Published on 2010-12-28T23:24:37Z Indexed on 2011/01/06 19:54 UTC
Read the original article Hit count: 241

I serve ads through an iFrame. The ad network's servers are much slower than mine, so I asyncronously load the iFrame after the window.onLoad event.

Event.observe(
 window,
 'load',
 function() {
  $('ad').writeAttribute('ad.html');
 }
);

A problem occurs when you enter the site via the browser's back button. Unexpectedly, the ad iFrame attempts to load immediately, delaying window.onLoad for a few seconds. During these few seconds, the site is unusable because I do a bunch of initialization after window.onLoad. As far as I know, this only happens in Firefox. How do I prevent this blocking load?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about firefox