Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE DOMContentLoaded documentElement.doScroll

Is there any reason why DOMContentLoaded trick for IE by Diego Perini is implemented only when window is not in iframe in popular JS Libraries?

jQuery:

//If IE and not a frame continually check to see if the document is ready

  var toplevel = false;

  try {
    toplevel = window.frameElement == null;
  } catch(e) {}

  if ( document.documentElement.doScroll && toplevel ) {
    doScrollCheck();
  }

Prototype:

document.observe('readystatechange', checkReadyState);
if (window == top)
  timer = pollDoScroll.defer();

Both of them checks is window is equal to top and if it is the document.documentElement.doScroll('left'); is used to check ready state. But why not to use it when window != top?

like image 309
Norbert Orzechowicz Avatar asked May 29 '12 14:05

Norbert Orzechowicz


1 Answers

This bug report for YUI library states that doScroll in framed document doesn't work the same way as when run on top level (doesn't throw errors when document isn't ready).

like image 195
Rafael Avatar answered Oct 22 '22 10:10

Rafael