IE DOMContentLoaded documentElement.doScroll

Is there a reason why Diego Perini's DOMContentLoaded IE trick is only implemented when the window is not in an 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 are a window equal to the top, and if used to check the status of readiness document.documentElement.doScroll('left');. But why not use it when window != top?

+5
source share
1 answer

This error report for the YUI library states that the doScroll in the frame document does not work as it does when it was launched at the top level (it does not generate errors when the document is not ready).

+5
source

All Articles