I need to root out iframes nested within iframes nested within iframes.
The structure for my code is shown below. It works fine in all browsers but in ie it results in an infinite loop. However, the cpu doesn’t get raised at all while it is in the infinite loop.
var getNested_iframes = function (document_element) {
$.each(document_element.find("iframe"), function () {
getNested_iframes($($(this)[0].document));
});
alert(".");
}
getNested_iframes($(myWindow._element));
alert("done");
I’m not quite sure why you’re doing it just like you’re doing it, but the “$($(this)[0].document)” bit looks a tch fishy to me. In any case, it’s worth noting that jquery objects are essentially lists of arbitrary size, so you can do this with iteration, rather than recursion (and swapping from recursion to iteration, when you can do it, often causes problems like this to simplify or clear up). Try the following
It even lets you track how many of them are at each level, how many levels there are, and so forth.